Skip to content

Conversation

@dragon-fish
Copy link
Member

@dragon-fish dragon-fish commented Nov 9, 2025

Sourcery 总结

为 InPageEdit 引入一个新的 Monaco 编辑器插件,该插件在快速编辑维基模态框中嵌入了一个由 Monaco 提供支持的代码编辑器,并将其打包为一个 ESM 库。

新功能:

  • 将 Monaco 编辑器实例附加到 quick-edit/wiki-page 事件,用现代 Monaco 编辑器替换文本区域。
  • 动态加载并初始化现代 Monaco,其主题、布局和语言设置从页面内容模型或文件名推断而来。
  • 提供辅助方法,通过标题扩展名/命名空间猜测语言、创建 Monaco 模型,并使用维基页面内容设置工作区。

构建:

  • 添加 package.json 文件,其中包含模块导出、构建脚本和 InPageEdit 插件元数据。
  • 配置 Vite 以输出 ES 模块库,并包含一个开发用的 HTML 入口点。
Original summary in English

Summary by Sourcery

Introduce a new Monaco Editor plugin for InPageEdit that embeds a monaco-powered code editor in the quick-edit wiki modal and packages it as an ESM library.

New Features:

  • Attach a Monaco Editor instance to the quick-edit/wiki-page event, replacing the textarea with a modern-monaco editor
  • Dynamically load and initialize modern-monaco with theme, layout, and language settings inferred from the page content model or filename
  • Provide helper methods to guess language by title extension/namespace, create monaco models, and set up workspaces with wiki page content

Build:

  • Add package.json with module exports, build scripts, and plugin metadata for InPageEdit
  • Configure Vite for ES module library output and include a development HTML entry point

@cloudflare-workers-and-pages
Copy link

Deploying ipe-plugin-registry with  Cloudflare Pages  Cloudflare Pages

Latest commit: 49796b2
Status: ✅  Deploy successful!
Preview URL: https://413a3c53.plugin-registry.pages.dev
Branch Preview URL: https://dragon-fish-monaco.plugin-registry.pages.dev

View logs

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 9, 2025

审阅者指南

此 PR 通过创建一个专用包,引入了一个新的 Monaco 编辑器插件,用于 InPageEdit。该插件会监听 quick-edit/wiki-page 事件,按需加载 modern-monaco 库,将配置好的编辑器注入到模态框中,并将其模型与底层 textarea 同步。

Monaco 编辑器在 quick-edit/wiki-page 事件中注入的序列图

sequenceDiagram
  participant InPageEdit
  participant PluginMonaco
  participant Modal
  participant MonacoEditor
  participant Textarea

  InPageEdit->>PluginMonaco: Emit quick-edit/wiki-page event
  PluginMonaco->>PluginMonaco: onQuickEditWikiPage(payload)
  PluginMonaco->>MonacoEditor: import modern-monaco & init
  PluginMonaco->>Modal: Find textarea and wrapper
  PluginMonaco->>MonacoEditor: Create editor in wrapper
  PluginMonaco->>MonacoEditor: Set editor model (from wikiPage)
  MonacoEditor->>Textarea: On model change, update textarea value
  Textarea->>Modal: Dispatch input/change events
Loading

PluginMonaco 及相关类型的类图

classDiagram
  class BasePlugin {
    <<abstract>>
    ctx: InPageEdit
  }
  class PluginMonaco {
    ctx: InPageEdit
    +constructor(ctx: InPageEdit)
    +start()
    +onQuickEditWikiPage(payload)
    +guessLangByTitle(input)
    +createWorkspace(wikiPage: IWikiPage)
    +createModel(monaco, wikiPage)
  }
  class InPageEdit {
    +on(event, handler)
    +set(key, value)
    wikiTitle: WikiTitleService
  }
  class IWikiPage {
    title: string
    contentmodel: string
    revisions: Revision[]
  }
  class Revision {
    content: string
  }
  class WikiTitleService {
    +newTitle(input): WikiTitle
  }
  class WikiTitle {
    +getNamespaceId()
    +getMainText()
  }
  BasePlugin <|-- PluginMonaco
  PluginMonaco o-- InPageEdit
  PluginMonaco o-- IWikiPage
  InPageEdit o-- WikiTitleService
  WikiTitleService o-- WikiTitle
  IWikiPage o-- Revision
Loading

文件级更改

更改 详情 文件
在快速编辑工作流中注册并初始化 Monaco 编辑器
  • 扩展 BasePlugin 并在构造函数中设置插件键
  • 在 start() 中监听 'quick-edit/wiki-page' 事件
  • 在事件处理程序中动态导入 modern-monaco init
  • 创建编辑器容器,配置选项,并附加到模态框
  • 通过 input/change 事件将模型值同步回 textarea
packages/monaco/src/index.ts
基于标题和内容模型实现语言检测
  • 添加 guessLangByTitle 以从文件扩展名和命名空间推断语言
  • 当未指定时,回退到 contentmodel 或默认为 'wikitext'
packages/monaco/src/index.ts
添加用于工作区和模型创建的辅助函数
  • 实现 createWorkspace 以使用初始文件初始化 Monaco 工作区
  • 实现 createModel 以使用正确的语言和内容实例化 Monaco 模型
packages/monaco/src/index.ts
设置 Monaco 插件包配置和构建
  • 添加 package.json,包含元数据、依赖项、导出和加载器配置
  • 配置 vite.config.ts 以进行库构建、别名解析和源映射
  • 包含 index.html 作为开发的基本示例
packages/monaco/package.json
packages/monaco/vite.config.ts
packages/monaco/index.html

提示和命令

与 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

This PR introduces a new Monaco editor plugin for InPageEdit by creating a dedicated package that hooks into the quick-edit/wiki-page event, lazily loads the modern-monaco library, injects a configured editor into the modal, and synchronizes its model with the underlying textarea.

Sequence diagram for Monaco editor injection on quick-edit/wiki-page event

sequenceDiagram
  participant InPageEdit
  participant PluginMonaco
  participant Modal
  participant MonacoEditor
  participant Textarea

  InPageEdit->>PluginMonaco: Emit quick-edit/wiki-page event
  PluginMonaco->>PluginMonaco: onQuickEditWikiPage(payload)
  PluginMonaco->>MonacoEditor: import modern-monaco & init
  PluginMonaco->>Modal: Find textarea and wrapper
  PluginMonaco->>MonacoEditor: Create editor in wrapper
  PluginMonaco->>MonacoEditor: Set editor model (from wikiPage)
  MonacoEditor->>Textarea: On model change, update textarea value
  Textarea->>Modal: Dispatch input/change events
Loading

Class diagram for PluginMonaco and related types

classDiagram
  class BasePlugin {
    <<abstract>>
    ctx: InPageEdit
  }
  class PluginMonaco {
    ctx: InPageEdit
    +constructor(ctx: InPageEdit)
    +start()
    +onQuickEditWikiPage(payload)
    +guessLangByTitle(input)
    +createWorkspace(wikiPage: IWikiPage)
    +createModel(monaco, wikiPage)
  }
  class InPageEdit {
    +on(event, handler)
    +set(key, value)
    wikiTitle: WikiTitleService
  }
  class IWikiPage {
    title: string
    contentmodel: string
    revisions: Revision[]
  }
  class Revision {
    content: string
  }
  class WikiTitleService {
    +newTitle(input): WikiTitle
  }
  class WikiTitle {
    +getNamespaceId()
    +getMainText()
  }
  BasePlugin <|-- PluginMonaco
  PluginMonaco o-- InPageEdit
  PluginMonaco o-- IWikiPage
  InPageEdit o-- WikiTitleService
  WikiTitleService o-- WikiTitle
  IWikiPage o-- Revision
Loading

File-Level Changes

Change Details Files
Register and initialize Monaco editor in quick-edit workflow
  • Extend BasePlugin and set plugin key in constructor
  • Listen to 'quick-edit/wiki-page' event in start()
  • Dynamically import modern-monaco init in event handler
  • Create editor container, configure options, and append to modal
  • Sync model value back to textarea via input/change events
packages/monaco/src/index.ts
Implement language detection based on title and content model
  • Add guessLangByTitle to infer language from file extension and namespace
  • Fallback to contentmodel or default to 'wikitext' when unspecified
packages/monaco/src/index.ts
Add helpers for workspace and model creation
  • Implement createWorkspace to initialize a Monaco workspace with initial files
  • Implement createModel to instantiate a Monaco model with correct language and content
packages/monaco/src/index.ts
Set up monaco plugin package configuration and build
  • Add package.json with metadata, dependencies, exports, and loader config
  • Configure vite.config.ts for library build, alias resolution, and sourcemaps
  • Include index.html as a basic example for development
packages/monaco/package.json
packages/monaco/vite.config.ts
packages/monaco/index.html

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

@dragon-fish dragon-fish changed the title feat: introduce monaco editor (temporary save) feat: introduce monaco editor Nov 9, 2025
@bhsd-harry
Copy link
Member

这个插件需要添加LSP支持吗?

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.

3 participants