Skip to content

Conversation

@LukeTowers
Copy link
Member

@LukeTowers LukeTowers commented Jan 1, 2026

Related: wintercms/winter#801

Screenshot 2026-01-02 at 1 07 41 AM Screenshot 2026-01-02 at 1 08 19 AM Screenshot 2026-01-02 at 1 08 45 AM

Summary by CodeRabbit

  • New Features

    • Visual indicators for new translation strings in the code editor with green highlighting.
    • Improved form widget handling for AJAX requests and nested editors.
  • Style

    • Updated color schemes and styling for inspector and control elements.
    • Enhanced visual feedback for hover and active states.
  • Refactor

    • Migrated code editor from ACE to Monaco for improved editing experience and decoration support.
    • Streamlined migration code generation with clearer operation tracking.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 1, 2026

Walkthrough

This PR migrates the code editor from ACE to Monaco, introduces AJAX-driven form widget reconstruction through a new behavior base class pattern, restructures migration code generation to use anonymous classes and separate up/down code blocks, and applies minor CSS styling updates with green highlighting classes for new translation indicators.

Changes

Cohort / File(s) Summary
UI/CSS Styling
assets/css/builder.css, assets/less/localization.less
Minor color/border/padding adjustments to inspector states, tab controls, and button styling. New helper classes (.builder-new-translation-line, .builder-new-translation-gutter) introduce semi-transparent green shading for new translation indicators. Some !important flags removed or adjusted.
JavaScript Editor Migration: ACE → Monaco
assets/js/build-min.js, assets/js/builder.index.entity.localization.js
Replaced direct ACE editor access (.editor property and session methods) with Monaco wrapper object. Method Localization.prototype.getCodeEditor now returns the wrapper instead of the editor instance. Calls to getSession().setValue() and getSession().setAnnotations() replaced with setValue() and setDecorations() on wrapper; decorations created using Monaco Range API with 1-based line indexing.
Form Widget AJAX Reconstruction Framework
classes/IndexOperationsBehaviorBase.php, behaviors/IndexDatabaseTableOperations.php, behaviors/IndexLocalizationOperations.php, behaviors/IndexVersionsOperations.php
Added constructor and handleFormWidgetAjax() handler to base class to intercept and reconstruct missing nested form widgets during AJAX requests. Each behavior implements reconstructFormWidget($alias) to rebuild form state from POST data, enabling CodeEditor and other nested widgets to function via AJAX without full page reload. Includes alias validation, pluginCode/language resolution, and form context binding.
Migration Object Generation
classes/DatabaseTableModel.php, classes/TableMigrationCodeGenerator.php
Updated createMigrationObject signature to accept $operation ('create'/'update'/'delete') and $tableName parameters. Migration script filenames now generated using operation and table name. wrapMigrationCode signature changed to accept separate $upCode and $downCode instead of combined $code. Template data keys updated to reflect up/down split.
Migration Code Templates
classes/databasetablemodel/templates/full-migration-code.php.tpl, classes/databasetablemodel/templates/migration-code.php.tpl
Full migration template now uses anonymous class syntax (return new class extends Migration) with separate up() and down() methods containing {upCode} and {downCode} blocks. Migration-code.php.tpl contents removed as its functionality absorbed into full template.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Controller
    participant IndexOpsBehavior as IndexOperations<br/>Behavior
    participant WidgetRegistry
    participant FormWidget
    
    Client->>Controller: AJAX request (widget-scoped handler)
    Controller->>IndexOpsBehavior: handleFormWidgetAjax($handler)
    
    rect rgb(200, 220, 255)
    Note over IndexOpsBehavior: Parse widget alias from handler
    IndexOpsBehavior->>WidgetRegistry: Check if widget exists
    WidgetRegistry-->>IndexOpsBehavior: Widget missing or not found
    end
    
    rect rgb(220, 240, 220)
    Note over IndexOpsBehavior: Reconstruct missing widget
    IndexOpsBehavior->>IndexOpsBehavior: reconstructFormWidget($alias)
    IndexOpsBehavior->>FormWidget: Build from POST data<br/>(form config, fields, alias)
    FormWidget->>FormWidget: Set context/language
    IndexOpsBehavior->>Controller: Bind widget to controller
    Controller->>WidgetRegistry: Register reconstructed widget
    WidgetRegistry-->>IndexOpsBehavior: Success
    end
    
    IndexOpsBehavior->>Controller: Continue normal handler flow
    Controller->>FormWidget: Execute AJAX action
    FormWidget-->>Client: AJAX response
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.43% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Support Monaco editor' directly and clearly describes the primary change across the changeset, which is replacing ACE editor interactions with Monaco editor support throughout multiple files.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

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.

2 participants