Skip to content

Conversation

@bhsd-harry
Copy link
Member

@bhsd-harry bhsd-harry commented Nov 20, 2025

WikiEditor toolbars are automatically loaded for textareas with id="wpTextbox1".

close #11

Sourcery 总结

错误修复:

  • 通过推迟 ext.wikiEditor 加载直到需要时,防止重复的 wiki 编辑器工具栏按钮
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Prevent duplicate wiki-editor toolbar buttons by deferring ext.wikiEditor loading until needed

WikiEditor toolbars are automatically loaded for textareas with `id="wpTextbox1"`.

close #11
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 20, 2025

审阅者指南 (在小型 PRs 中折叠)

审阅者指南

此 PR 重新组织了 ext.wikiEditor 模块的加载方式,通过在检查 addWikiEditor 函数是否存在之后才延迟加载器,确保 addWikiEditor 只被调用一次,从而防止重复的工具栏按钮。

WikiEditor 工具栏初始化逻辑的序列图

sequenceDiagram
participant Plugin as "WikiEditor Plugin"
participant mw as "window.mw"
participant Loader as "mw.loader"
participant Textarea as "wpTextbox1 textarea"

Plugin->>Textarea: Check for textarea and registration
alt addWikiEditor exists
  Plugin->>mw: Call addWikiEditor($(textarea))
else addWikiEditor does not exist
  Plugin->>Loader: Load 'ext.wikiEditor'
end
Loading

文件级别变更

变更 详情 文件
重新排序 ext.wikiEditor 加载以消除重复的工具栏初始化
  • 移除了在检查 addWikiEditor 之前无条件的 mw.loader.using 调用
  • 添加了条件 else 分支,仅当 addWikiEditor 尚不可用时才加载 ext.wikiEditor
  • 将 addWikiEditor 调用包装在存在性检查中
packages/wiki-editor/src/index.ts

相关问题评估

问题 目标 已解决 解释
#11 移除 Wiki 编辑器中 id="wpTextbox1" 文本区域工具栏上的重复图标。

可能相关的问题


提示和命令

与 Sourcery 互动

  • 触发新审查: 在拉取请求上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 通过回复 Sourcery 的审查评论,要求它创建一个 issue。您也可以回复审查评论并带上 @sourcery-ai issue 来创建一个 issue。
  • 生成拉取请求标题: 随时在拉取请求标题中的任何位置写入 @sourcery-ai 以生成标题。您也可以在拉取请求上评论 @sourcery-ai title 以随时(重新)生成标题。
  • 生成拉取请求摘要: 随时在拉取请求正文中的任何位置写入 @sourcery-ai summary,以在您需要的位置生成 PR 摘要。您也可以在拉取请求上评论 @sourcery-ai summary 以随时(重新)生成摘要。
  • 生成审阅者指南: 在拉取请求上评论 @sourcery-ai guide 以随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在拉取请求上评论 @sourcery-ai resolve 以解决所有 Sourcery 评论。如果您已经处理了所有评论,并且不想再看到它们,这会很有用。
  • 驳回所有 Sourcery 审查: 在拉取请求上评论 @sourcery-ai dismiss 以驳回所有现有的 Sourcery 审查。如果您想重新开始新的审查,这会特别有用——别忘了评论 @sourcery-ai review 来触发新的审查!

自定义您的体验

访问您的 仪表盘 以:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审阅者指南以及其他功能。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR reorganizes the loading of the ext.wikiEditor module so that addWikiEditor is invoked only once, preventing duplicate toolbar buttons by deferring the loader until after checking for the existence of the addWikiEditor function.

Sequence diagram for WikiEditor toolbar initialization logic

sequenceDiagram
participant Plugin as "WikiEditor Plugin"
participant mw as "window.mw"
participant Loader as "mw.loader"
participant Textarea as "wpTextbox1 textarea"

Plugin->>Textarea: Check for textarea and registration
alt addWikiEditor exists
  Plugin->>mw: Call addWikiEditor($(textarea))
else addWikiEditor does not exist
  Plugin->>Loader: Load 'ext.wikiEditor'
end
Loading

File-Level Changes

Change Details Files
Reorder ext.wikiEditor loading to eliminate duplicate toolbar initialization
  • Removed unconditional mw.loader.using call before checking addWikiEditor
  • Added conditional else branch to load ext.wikiEditor only when addWikiEditor is not yet available
  • Wrapped addWikiEditor invocation in an existence check
packages/wiki-editor/src/index.ts

Assessment against linked issues

Issue Objective Addressed Explanation
#11 Remove duplicate icons from the toolbar in the Wiki Editor for textareas with id="wpTextbox1".

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好 - 我已经审阅了你的修改,它们看起来很棒!


Sourcery 对开源项目免费 - 如果你喜欢我们的评论,请考虑分享它们 ✨
帮助我更有用!请在每条评论上点击 👍 或 👎,我将利用这些反馈来改进你的评论。
Original comment in English

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 20, 2025

Deploying ipe-plugin-registry with  Cloudflare Pages  Cloudflare Pages

Latest commit: 331ad25
Status: ✅  Deploy successful!
Preview URL: https://743c403a.plugin-registry.pages.dev
Branch Preview URL: https://bhsd-wiki-editor.plugin-registry.pages.dev

View logs

There are two entries of `@bhsd/codemirror-mediawiki`: [wiki.min.js](https://cdn.jsdelivr.net/npm/@bhsd/codemirror-mediawiki/dist/wiki.min.js) is IIFE and [mw.min.js](https://cdn.jsdelivr.net/npm/@bhsd/codemirror-mediawiki/dist/mw.min.js) is ESM. Wikiplus uses wiki.min.js while IPE uses mw.min.js, which means the package may be loaded twice on the same page.
@dragon-fish
Copy link
Member

我需要确认一下,是否可以移除 IPE 的 id="wpTextbox1"
我不确定当初为什么要添加它,似乎属于历史遗留问题,它是否被某个插件依赖?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][wiki-editor]工具栏中图标存在重复

3 participants