Skip to content

feat: add spellCheck support to the editor#950

Open
youdie006 wants to merge 1 commit into
eigenpal:mainfrom
youdie006:feat/spellcheck-support
Open

feat: add spellCheck support to the editor#950
youdie006 wants to merge 1 commit into
eigenpal:mainfrom
youdie006:feat/spellcheck-support

Conversation

@youdie006

@youdie006 youdie006 commented Jun 20, 2026

Copy link
Copy Markdown

Summary

The editor did not enable the browser-native spellchecker — no spellcheck attribute was set on the ProseMirror editable surface (#32).

Fix

Add a spellCheck prop (default true) that sets spellcheck on the body editable surface and keeps it in sync on change.

  • React: threaded through DocxEditorDocxEditorPagedAreaPagedEditorHiddenProseMirror, mirroring how readOnly flows.
  • Vue: a spellCheck option on useDocxEditor (with a withDefaults default) and the public prop on DocxEditor.vue.
  • Scope: body editable only; header/footer chrome left untouched.

Includes the parity-contract entry, regenerated API snapshots, and a changeset. Verified in both the React and Vue demos — the body editable shows spellcheck="true", header/footer unaffected.

Closes #32


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

The editor did not enable the browser-native spellchecker - no spellcheck
attribute was set on the ProseMirror editable surface. Add a spellCheck prop
(default true) that sets spellcheck on the body editable surface and keeps it in
sync on change. React threads it through DocxEditor -> DocxEditorPagedArea ->
PagedEditor -> HiddenProseMirror (mirroring readOnly); Vue exposes it via a
useDocxEditor option and the DocxEditor.vue prop. Body editable only; header and
footer chrome are untouched. Includes the parity-contract entry, regenerated API
snapshots, and a changeset.

Closes eigenpal#32
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docx-editor Ready Ready Preview, Comment Jun 20, 2026 12:49am

Request Review

@eigenpal-release-pal

eigenpal-release-pal Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅

Posted by the CLA bot.

@greptile-apps

greptile-apps Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a spellCheck prop (default true) to both React and Vue adapters that sets the spellcheck attribute on the ProseMirror body editable surface. Header/footer editors are intentionally left untouched.

  • React: prop is threaded DocxEditorDocxEditorPagedAreaPagedEditorHiddenProseMirror, seeded in ProseMirror's attributes config at construction and kept in sync via a useEffect; mirrors the existing readOnly propagation pattern exactly.
  • Vue: spellCheck added to UseDocxEditorOptions as MaybeRef<boolean>, seeded in the new EditorView constructor's attributes, and kept live via watch([() => unref(spellCheck), editorView], ...) with immediate: true.
  • API snapshots, parity contract, changeset, and a new test file (initial-render cases only) are all included.

Confidence Score: 4/5

Safe to merge; the change is additive with a sensible default and cannot break existing behaviour.

Both React and Vue paths correctly seed the attribute at view construction and keep it live on prop changes. The only gap is the test suite, which only verifies the initial-render state and would not catch a regression in the dynamic prop-change effect.

packages/react/src/components/DocxEditor/spellcheck.test.tsx — would benefit from a rerender test covering the prop-change effect path.

Important Files Changed

Filename Overview
packages/react/src/components/DocxEditor/HiddenProseMirror.tsx Adds spellCheck prop: seeds the attribute in the ProseMirror attributes config at construction and keeps it in sync via a useEffect; pattern mirrors readOnly correctly.
packages/react/src/components/DocxEditor/spellcheck.test.tsx Tests the static initial-render cases; missing a rerender test for the dynamic prop-change effect path.
packages/vue/src/composables/useDocxEditor.ts Adds spellCheck as MaybeRef; seeds it in EditorView attributes and tracks changes via watch([() => unref(spellCheck), editorView]), matching the readOnly watcher pattern.
packages/vue/src/components/DocxEditor.vue Adds spellCheck prop with withDefaults default of true; threads it into useDocxEditor as a computed ref, consistent with how readOnly is wired.
packages/react/src/components/DocxEditor.tsx Adds spellCheck prop (default true) and threads it down through DocxEditorPagedArea, mirroring the readOnly propagation chain.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph React
        A["DocxEditor\n(spellCheck prop, default true)"] --> B["DocxEditorPagedArea\n(spellCheck: boolean)"]
        B --> C["PagedEditor\n(spellCheck?: boolean)"]
        C --> D["HiddenProseMirror\n(attributes seed + useEffect sync)"]
    end
    subgraph Vue
        E["DocxEditor.vue\n(withDefaults spellCheck: true)"] --> F["useDocxEditor()\nspellCheck: computed(() => props.spellCheck)"]
        F --> G["new EditorView\n(attributes seed at construction)"]
        F --> H["watch([unref(spellCheck), editorView])\nDOM setAttribute on change"]
    end
    D --> Z["view.dom spellcheck attr"]
    G --> Z
    H --> Z
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    subgraph React
        A["DocxEditor\n(spellCheck prop, default true)"] --> B["DocxEditorPagedArea\n(spellCheck: boolean)"]
        B --> C["PagedEditor\n(spellCheck?: boolean)"]
        C --> D["HiddenProseMirror\n(attributes seed + useEffect sync)"]
    end
    subgraph Vue
        E["DocxEditor.vue\n(withDefaults spellCheck: true)"] --> F["useDocxEditor()\nspellCheck: computed(() => props.spellCheck)"]
        F --> G["new EditorView\n(attributes seed at construction)"]
        F --> H["watch([unref(spellCheck), editorView])\nDOM setAttribute on change"]
    end
    D --> Z["view.dom spellcheck attr"]
    G --> Z
    H --> Z
Loading

Reviews (1): Last reviewed commit: "feat: add spellCheck support to the edit..." | Re-trigger Greptile

Comment on lines +28 to +38
describe('HiddenProseMirror spellcheck', () => {
test('enables the browser-native spellchecker by default', () => {
const dom = renderEditor({});
expect(dom.getAttribute('spellcheck')).toBe('true');
});

test('disables the spellchecker when spellCheck is false', () => {
const dom = renderEditor({ spellCheck: false });
expect(dom.getAttribute('spellcheck')).toBe('false');
});
});

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.

P2 Missing test for dynamic prop-change

The suite only checks the attribute at initial render; the useEffect(() => { view.dom.setAttribute(...) }, [spellCheck]) path — which is the one that actually matters when a host app toggles the prop at runtime — is never exercised. If that effect were accidentally removed or had a stale closure, both static tests would still pass. A third test that renders with spellCheck={true}, then re-renders with spellCheck={false} (via rerender from RTL) and re-reads dom.getAttribute('spellcheck') would cover the dynamic case.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@youdie006

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

eigenpal-release-pal Bot added a commit that referenced this pull request Jun 20, 2026
@youdie006

Copy link
Copy Markdown
Author

!cla-check

@jedrazb

jedrazb commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Hey @youdie006 Could you attach a short screen recording or screenshot showing the spellcheck actually rendering on the page?

The wiring looks correct (prop threaded through both adapters, defaults right, parity contract + API snapshots updated, typecheck/test/parity all green), but I want to confirm the feature is visible to the user before merging. The spellcheck attribute is set on the hidden ProseMirror surface. So I'd like to verify the browser-native underlines actually show up on the visible pages and aren't just being painted on the offscreen editing surface where nobody can see them.

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.

Spellcheck support

2 participants