-
Notifications
You must be signed in to change notification settings - Fork 418
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: Cannot read properties of undefined (reading 'createBtn') #303 #304
Conversation
… dev merge upstream dev branch
@@ -134,7 +134,7 @@ export default class HookCenter { | |||
if (HookList[name]) { | |||
this.allMenusName.push(name); | |||
this.hooks[name] = new HookList[name]($cherry); | |||
} else if (customMenu[name]) { | |||
} else if (customMenu !== undefined && customMenu !== null && customMenu[name]) { |
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.
用可选链就好了,不用写这么长。customMenu?.[name]
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.
确实是,这点没注意,case by case 了,这个被merge了,我问问
@sunsonliu 需不需要改一下
subMenu.dom = subMenu.dom ? subMenu.dom : this.menus.hooks[name].dom; | ||
btn.addEventListener('click', (event) => this.onClick(event, level2Name, true), false); | ||
this.subMenus[name].appendChild(btn); | ||
} |
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.
提早 return,减少嵌套。
if (typeof subMenu?.createBtn !== 'function') {
return;
}
const xxxxx;
// ....
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.
学到了,又是一个优雅的写法
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.
@sunsonliu 说下次一起提,我先在本地改好
* feat: add ruby syntax * feat: 增加ruby语法(拼音语法)的toolbar和demo * feat(eslint): setup husky and lint-staged * chore(codespaces): setup codespace dev container * chore(*): normalize eol * chore(*): revert merge conflicts & normalize eol * chore(codespaces): add vscode settings to devcontainer * chore(codespaces): fix eslint extension settings * chore(codespaces): run dev script at postStart * chore(codespaces): run yarn install only * feat: update sidebar style * docs: update readme & test command * chore(husky/lint-staged): rollback husky@7 & lint-staged@12 for node 12 * Feat: 增加新的图片懒加载机制 * 修复lint报错 * fix: 编辑时更新预览时,DOM若存在相邻的 TextNode 会导致文字渲染两次 * fix: vdom的style写法有误导致每次都会重建元素 * feat: support data-cm-atomic for dom plugins * chore(*): build * chore(release): 0.7.7 * fix: install husky when dev only (Tencent#289) * fix: install husky when dev only * chore(release): 0.7.8 * style: remove ambiguous css reset * fix(imageLazyLoad): 修复懒加载开关配置 * chore(release): 0.7.9 * build(deps): bump terser from 4.8.0 to 4.8.1 Bumps [terser](https://github.com/terser/terser) from 4.8.0 to 4.8.1. - [Release notes](https://github.com/terser/terser/releases) - [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md) - [Commits](https://github.com/terser/terser/commits) --- updated-dependencies: - dependency-name: terser dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * feat: 实现快捷键显示/隐藏toolbar Tencent#268 * feat: 通过快捷键来实现显示|隐藏 toolbar 或 设置按钮子菜单隐藏toolbar Tencent#268 * fix: 无法使用Ctrl+Shift组合键 Tencent#290 * fix: lint err Expected '!==' and instead saw '!=' * Feat/selection (Tencent#300) feat: 优化选区逻辑,这次提交先做了加粗和斜体 Tencent#280 feat: 重构工具栏机制,支持多个独立菜单自由组合的机制 1、增加选区控制逻辑(目前支持了加粗、斜体、代码块,剩余的继续完善) 2、新增了独立菜单自由组合的能力 3、新增了菜单异步回调逻辑(如上传视频、选择颜色、通过棋盘插入表格等) 4、继续支持旧的二级菜单逻辑 5、新增菜单统一管理机制 6、初步改造了下快捷键机制(后续继续优化) * fix: Tencent#301 (Tencent#302) * fix: Cannot read properties of undefined (reading 'line-table') Tencent#301 * fix: Cannot read properties of undefined (reading 'line-table') Tencent#301 * fix: Cannot read properties of undefined (reading 'createBtn') Tencent#303 (Tencent#304) * fix: Cannot read properties of undefined (reading 'createBtn') Tencent#303 * feat: 优化toolbar插入内容时的选区逻辑 * feat: 优化字体大小按钮的选区,并增加快捷键 * fix: 暗黑模式下调色盘文字看不清楚 * Feature/bubble refactor (Tencent#314) * chore(build): ignore circular dependency * refactor(bubble): refactor bubble toolbar - use flexbox instead of hard-code positions - split bubble toolbar styles into individual file - simply implemented locale module for i18n * feat(i18n): move utils/locale to locales * chore(release): 0.8.0 * fix: 懒加载逻辑不能幂等 * chore(release): 0.8.1 * Update extensions.md * Update extensions.CN.md Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: ObjectKaz <objectkaz@163.com> Co-authored-by: sunsonliu <sunsonliu@tencent.com> Co-authored-by: lyngai <wlxjust@gmail.com> Co-authored-by: jiawei686 <892001108@qq.com> Co-authored-by: lyonbot <lyonbot@outlook.com> Co-authored-by: humyfred <513407656@qq.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: ufec <ufec@qq.com> Co-authored-by: ThinkHalo <1750367868@qq.com>
…t#303 (Tencent#304) * fix: Cannot read properties of undefined (reading 'createBtn') Tencent#303
需要做判断,应该还是那个
line-table
的问题