Skip to content

refactor(text-editor): extract editor-config to enable real-stack testing#4139

Open
john-traas wants to merge 4 commits into
mainfrom
text-editor-real-stack-tests
Open

refactor(text-editor): extract editor-config to enable real-stack testing#4139
john-traas wants to merge 4 commits into
mainfrom
text-editor-real-stack-tests

Conversation

@john-traas

@john-traas john-traas commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What

Extracts the text editor's schema and plugin assembly out of the limel-prosemirror-adapter component into a pure, importable module, and adds an integration test that exercises the real editor stack.

  • refactor: initializeSchema() / createEditorState() (private methods on the adapter) → pure buildEditorSchema() / buildEditorPlugins() in editor-config.ts. The component delegates to them; plugin order and behaviour are preserved exactly.
  • test: editor-config.spec.ts builds the production schema + the real ordered plugin list and asserts, using the official prosemirror-test-builder:
    • commands produce the expected transaction;
    • the link/image handlePaste ordering contract (ProseMirror is first-truthy-wins) — guarding against a new/changed plugin silently shadowing another on a shared event;
    • a transaction sequence keeps the document structurally valid.
  • build: adds a clean script (shx rm -rf .stencil dist www) and the prosemirror-test-builder dev dependency.

Why

The editor is now used across the CRM, so we need regression coverage for cross-plugin interactions (paste / keymap / transaction chains). Those only surface when the real, full plugin set runs against the real schema — previously impossible because the schema and plugin list were private to the component. This unblocks that, tests against source (immune to stale-dist issues), and needs no bespoke test-harness suite.

Verification

  • npm run test:spec: 884/884 pass (incl. the new spec)
  • text-editor e2e: 14/14 pass
  • Behaviour-preserving: no plugin order or logic changes.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a cleanup script to remove generated build output.
    • Introduced shared schema and plugin configuration for the ProseMirror text editor.
    • Added real-stack integration coverage validating editor commands, paste handling, and document integrity.
  • Bug Fixes
    • Ensured consistent editor schema/commands across supported content types.
    • Improved paste-handler behavior by enforcing correct ordering for link vs. image handling and non-link paste behavior.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3eff7bda-d51b-4153-b3ae-d511c713c253

📥 Commits

Reviewing files that changed from the base of the PR and between 74f39e1 and 719d673.

📒 Files selected for processing (1)
  • src/components/text-editor/prosemirror-adapter/editor-config.spec.ts

📝 Walkthrough

Walkthrough

A shared ProseMirror schema and plugin builder were extracted into editor-config.ts, and the text editor adapter now builds its editor state through those helpers. New integration tests cover schema contents, command execution, plugin ordering, and transaction validity, and package.json adds a clean script plus a test helper dependency.

Changes

ProseMirror editor configuration

Layer / File(s) Summary
Schema contract and types
src/components/text-editor/prosemirror-adapter/editor-config.ts
Defines the editor content type, schema options, and schema builder that extends the base schema with custom nodes and marks.
Plugin contract and ordering
src/components/text-editor/prosemirror-adapter/editor-config.ts
Defines the plugin options and the ordered plugin builder that assembles setup, keymaps, trigger, link, image, menu, action bar, and table plugins.
Adapter wiring to shared builders
src/components/text-editor/prosemirror-adapter/prosemirror-adapter.tsx
Replaces inline schema and plugin construction in the adapter with calls to the shared schema and plugin builders.
Integration tests and toolchain support
package.json, src/components/text-editor/prosemirror-adapter/editor-config.spec.ts
Adds the test builder dependency, a clean script, and integration tests for schema contents, command execution, plugin ordering, and transaction validity.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Lundalogik/lime-elements#3562: Refactors ProseMirror schema/plugin construction, including link mark and paste-handling wiring that overlaps with this editor configuration change.

Suggested reviewers

  • civing
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main refactor and the new real-stack testing goal.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch text-editor-real-stack-tests

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-4139/

@john-traas john-traas force-pushed the text-editor-real-stack-tests branch from b817bc0 to 74f39e1 Compare June 17, 2026 13:22
@john-traas john-traas self-assigned this Jun 18, 2026
@john-traas john-traas marked this pull request as ready for review June 26, 2026 08:57
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