资讯详情

资讯详情

CKEditor 4 通知内链接颜色对比度修复解析:以 linkcontrastkama 手动测试为例

前端UI组件【免费下载链接】ckeditor4The best enterprise-grade WYSIWYG editor. Fully customizable with countless features and plugins.项目地址https://gitcode.com/gh_mirrors/ck/ckeditor4点击查看免费下载CKEditor 4 的 Notification通知插件用于在编辑器中以非阻塞方式向用户展示短消息如上传进度、操作结果其消息文本中可以嵌入 HTML 链接。本篇技术指南以仓库内 linkcontrastkama.md 手动测试文档为核心讲解 CKEditor 4.22.0 中修复的“通知内链接颜色对比度不足”问题梳理该问题的复现步骤、修复后的预期行为、底层样式实现原理以及如何在 kama、moono、moono-lisa 三套皮肤下验证效果。读完本文你将掌握该 bug 的来龙去脉、notification插件与皮肤样式表CSS的联动机制并能独立运行与扩展这套手动测试。关联文档与测试背景linkcontrastkama.md位于 tests/plugins/notification/manual/ 目录是一份 Bender 手动测试manual test说明文档。其文件头部的元信息标记定义了测试的运行环境与定位bender-ui: collapsed bender-tags: bug, 4.22.0, 5495 bender-ckeditor-plugins: wysiwygarea, toolbar, notificationbender-ui: collapsed测试页面默认折叠 UI避免手动测试时界面干扰bender-tags: bug, 4.22.0, 5495声明这是一条 bug 类测试涉及 CKEditor 4.22.0 版本对应 GitHub issue 编号 5495bender-ckeditor-plugins测试页面加载wysiwygarea、toolbar、notification三个插件保证编辑器外壳、工具栏与通知能力齐全。在 CHANGES.md 的 CKEditor 4.22.0 变更记录中可以找到这条修复的官方说明#5495: Fixed: Insufficient color ratio for links inside Notifications.即“修复通知内部链接的颜色对比度不足”。linkcontrastkama.md正是该修复在kama 皮肤下的回归验证用例。与之并行的还有 linkcontrastmoono.md 与 linkcontrastmoonolisa.md分别覆盖 moono 与 moono-lisa 皮肤三份文档共用同一份测试思路。手动测试步骤与预期结果linkcontrastkama.md给出的测试步骤非常简洁使用编辑器下方的按钮打开通知Open notifications using the buttons under the editor.验证通知内部的链接是否与其余文本颜色相同Verify if links inside them have the same color as the rest of the text.。预期结果Expected链接与其余文本颜色相同Links have the same color as the rest of the text.。也就是说修复后的行为是无论通知文本中是否包含a链接链接的文字颜色都应继承通知消息的整体颜色不再出现“链接被浏览器默认样式染成蓝色、与通知背景对比度不足”的情况。测试页面构造三个按钮对应三种通知类型与.md文档配套的 linkcontrastkama.html 提供了可运行的测试页面其结构如下一个 id 为editor的div作为编辑器初始化容器含pHi!/p占位内容编辑器下方的三个按钮infoShow info、successShow success、warningShow warning页面脚本通过CKEDITOR.replace( editor, { skin: kama, ... })以kama 皮肤初始化编辑器并在instanceReady回调中为三个按钮绑定点击事件。按钮绑定的事件代码完整如下摘自 linkcontrastkama.htmlCKEDITOR.replace( editor, { skin: kama, on: { instanceReady: function( evt ) { var editor evt.editor, message a hrefhttps://ckeditor.comlink/a text; CKEDITOR.document.getById( info ).on( click, function() { editor.showNotification( message, info, 0 ); } ); CKEDITOR.document.getById( success ).on( click, function() { editor.showNotification( message, success, 0 ); } ); CKEDITOR.document.getById( warning ).on( click, function() { editor.showNotification( message, warning, 0 ); } ); } } } );关键点在于消息内容message a hrefhttps://ckeditor.comlink/a text它刻意在通知消息中嵌入一个a超链接。测试者依次点击三个按钮就能分别在info、success、warning三种通知类型中观察链接的颜色表现从而全面验证修复在不同配色背景下是否都生效。底层实现notification 插件的消息渲染要理解链接颜色为何会出现问题需要先看通知元素是如何渲染出来的。通知插件的实现位于 plugins/notification/plugin.js。插件在初始化时覆盖了编辑器的showNotification方法plugin.js该方法接受message、type、progressOrDuration三个参数内部构造CKEDITOR.plugins.notification实例并调用其show()editor.showNotification function( message, type, progressOrDuration ) { var progress, duration; if ( type progress ) { progress progressOrDuration; } else { duration progressOrDuration; } var notification new CKEDITOR.plugins.notification( editor, { message: message, type: type, progress: progress, duration: duration } ); notification.show(); return notification; };测试代码中第三个参数传0即duration 0表示通知不会自动关闭需要手动点击关闭按钮或按 ESC 关闭这为测试者留出了充分的观察时间。在_createElement()方法中plugin.js每个通知会生成如下的 DOM 结构div classcke_notification cke_notification_info rolealert aria-labelinfo p classcke_notification_message消息内容可含 a 链接/p a classcke_notification_close hrefjavascript:void(0) rolebutton tabindex-1 span classcke_labelX/span /a /div其中消息段落.cke_notification_message通过setHtml( this.message )直接注入 HTML——这正是a hrefhttps://ckeditor.comlink/a text能作为真实链接渲染出来的原因。通知类型与 CSS 类的对应关系由_getClass()决定plugin.jsinfo、success、warning分别映射为cke_notification_info、cke_notification_success、cke_notification_warningprogress类型复用cke_notification_info类。修复核心CSS 中的 color: inherit 规则问题修复的关键落在皮肤的样式表上。三套皮肤各自维护一份 notification.cssskins/kama/notification.cssskins/moono/notification.cssskins/moono-lisa/notification.css三份样式表中都包含同一条规则这正是 #5495 修复的样式核心.cke_notification_message a { color: inherit; }这条规则的作用是强制通知消息内部所有a链接的文字颜色继承父级文本颜色。修复前链接会被浏览器默认样式通常是蓝色、带下划线渲染而在通知的彩色背景如 kama 的 info 蓝色、success 绿色、warning 橙色上默认链接蓝与背景的对比度不足insufficient color ratio影响可读性与可访问性。加上color: inherit后链接颜色与其余文本保持一致对比度问题随之消除。三套皮肤的配色差异虽然修复规则相同但三套皮肤的通知配色不同这正是需要分别编写linkcontrastkama、linkcontrastmoono、linkcontrastmoonolisa三份测试的原因皮肤通知文字颜色info 背景success 背景warning 背景kama#222深灰kama/notification.css#54D3EC#96CA0A#FD7C44moonowhitemoono/notification.css#2E9AD0#72B572#C83939moono-lisawhitemoono-lisa/notification.css#2E9AD0#72B572#C83939kama 皮肤的通知文字为深灰色#222而 moono 与 moono-lisa 为白色因此在三套皮肤上都需要确认color: inherit生效后链接与对应文字颜色完全一致。CSS 注释还进一步解释了通知的 DOM 结构见各 notification.css 头部注释info/success/warning共享“消息段落 关闭按钮”的结构progress则在消息上方多一个.cke_notification_progress进度条元素。通知插件的其他行为细节与测试的关联自动关闭与 durationinfo与success类型默认在notification_duration毫秒后自动关闭配置项默认值为5000见 plugin.js 中的CKEDITOR.config.notification_duration文档注释warning与progress永远不会自动关闭。若显式传入duration 0如本测试则所有类型都不自动关闭。ESC 关闭与无障碍插件监听了编辑器key事件plugin.js当按下 ESC 时会播报notification.closed英文语言包为 Notification closed.见 plugins/notification/lang/en.js并隐藏最后一条通知同时以aria-live断言方式向屏幕阅读器同步状态。可取消事件show、update、hide分别触发notificationShow、notificationUpdate、notificationHide三个可取消事件plugin.js开发者可借此将编辑器通知与站点自身的通知体系集成或拦截默认显示行为。自动化测试方面tests/plugins/notification/notification.js 会断言通知 DOM 元素的rolealert属性、cke_notification_*类名以及进度条宽度等细节notification.js与手动测试形成互补。如何运行这份手动测试该手动测试运行于 CKEditor 4 自带的 Bender 测试框架。仓库根目录的 bender.js 定义了测试分组Plugins组覆盖plugins/**路径tests/_benderjs/ckeditor提供了 Bender 的 CKEditor 扩展。运行方式大致为在仓库根目录执行npm install安装依赖含 Bender 相关包启动 Bender 服务并指定浏览器例如bender server run配合bender run --browser chrome打开手动测试列表进入tests/plugins/notification/manual/linkcontrastkama.html依次点击Show info、Show success、Show warning三个按钮逐一核对通知内link链接的文字颜色是否与text一致。如果链接仍呈现与消息文本不同的颜色如蓝色则说明color: inherit规则失效或被其他样式覆盖即可判定回归。总结CKEditor 4.22.0 通过.cke_notification_message a { color: inherit; }这一条规则解决了通知内链接颜色对比度不足的问题issue #5495。linkcontrastkama.md 与其配套的 HTML 页面以及 moono、moono-lisa 两个变体测试共同构成了该修复的跨皮肤回归防线。理解这组测试既能掌握 notification 插件“消息可含 HTML、样式由皮肤决定”的架构特点也能在自定义皮肤或主题时避免重蹈对比度覆辙——记得让通知内的链接color: inherit。赞分享前端UI组件【免费下载链接】ckeditor4The best enterprise-grade WYSIWYG editor. Fully customizable with countless features and plugins.项目地址https://gitcode.com/gh_mirrors/ck/ckeditor4点击查看免费下载相关推荐CKEditor 4 通知内链接颜色修复5495moono-lisa 皮肤下链接与正文同色的实现与手动验证CKEditor 4 通知内链接颜色修复 5495moono lisa 皮肤下链接与正文同色的实现与手动验证 导读 本文围绕 CKEditor 4 在 4前端UI组件CKEditor 4 Notification 插件链接对比度修复moono 皮肤手动测试与 color: inherit 实现剖析CKEditor 4 Notification 插件链接对比度修复moono 皮肤手动测试与 color: inherit 实现剖析 本文以 CKEditor前端UI组件CKEditor 4 copyformatting 插件 Safari 颜色样式回归测试深度解析safaricolor 手册用例与源码级修复原理CKEditor 4 copyformatting 插件 Safari 颜色样式回归测试深度解析safaricolor 手册用例与源码级修复原理 导读 本篇文前端UI组件上一篇Apache RocketMQ 副本组 Quorum Write 与自适应降级Adaptive Downgrade实现解析下一篇Stylus TextMate Bundle 安装与使用指南从 make install-bundle 到语法高亮、⌘B 编译与偏好设置创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
觉得有用,分享给同行:

为您的企业打造数字门面

稳重轻奢商务风格,端正雅致视觉,长效耐看不易过时。

立即咨询 →