feat: add MS Office-like WYSIWYG editor (@office-kit/docx-editor)#21
Open
baseballyama wants to merge 1 commit into
Open
feat: add MS Office-like WYSIWYG editor (@office-kit/docx-editor)#21baseballyama wants to merge 1 commit into
baseballyama wants to merge 1 commit into
Conversation
Introduce an interactive Word/Google-Docs-like editing experience on top of @office-kit/docx, plus the library primitives it needs. - New @office-kit/docx-editor package: EditorModel (undo/redo), a command layer routed entirely through the @office-kit/docx public API, an AST→HTML canvas renderer with caret preservation, and DOM-selection mapping. - Completeness is enforced by a capability ledger over the ECMA-376 schema universe (1198 elements): every element is classified edit/render/preserve and a test fails on any unclassified element or dangling command. A two-tier raw-XML inspector (document-inline + any XML part) makes every element editable, so preserve is 0. - Interactive editing: Enter splits at the caret, Backspace/Delete merge paragraphs, caret survives structural re-renders, Ctrl+Z/Y undo/redo, plain-text paste, live word/char count, find & replace, zoom. - Selection-precise character formatting: bolding part of a line now splits runs at the selection boundaries and formats only the selected text (previously the whole line was affected). - Ribbon UI localized into 6 languages (en/ja/es/fr/de/zh) with a switcher. Library gains generic property setters, settings/style/numbering/part editors, image resize/alt-text, and caret-level structure ops (splitParagraphAt, mergeParagraphIntoPrevious, isolateParagraphRunRange, runTextLength). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XVrzeDdRi264e3WVfuMHak
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
@office-kit/docx-editor— an interactive, Word/Google-Docs-like editing experience on top of@office-kit/docx, shipped as a live UI at the site's/editorroute. Every edit routes through the@office-kit/docxpublic API (the library stays the single source of truth), and a capability ledger over the full ECMA-376 element universe mechanically guarantees that no document representation is silently dropped.Motivation
Goal: an MS Office-like editing UI that can realize all docx representations, with a mechanism that guarantees feature coverage — then raise the actual editing experience to at least match Google Docs. The ledger answers "when is it done?" objectively (unclassified elements fail the build), and the two-tier raw-XML inspector makes every element reachable, so
preserveis 0 (everything is editable or rendered). The editing surface was then made genuinely usable: real caret handling, paragraph split/merge, undo/redo, find & replace, selection-precise formatting, and localization.No pre-existing issue — this is the feature work requested directly.
Changes
@office-kit/docx-editor:EditorModel(undo/redo), command layer, AST→HTML canvas renderer with caret preservation, DOM-selection mapping, capability ledger + enforcing test.@office-kit/docxpublic API: generic run/paragraph/container property setters; settings/style/numbering editors; image resize & alt-text; raw element + raw XML part editors (getRawPartRoot/xmlPartNames/…); caret-level structure opssplitParagraphAt/mergeParagraphIntoPrevious; selection opsisolateParagraphRunRange/runTextLength. Also re-exportsXmlElement/XmlNode/XmlAttr/QNameand several option/property types.Testing
pnpm test— 524 passing / 5 skipped, including new suites: selection-aware formatting (text-selection.test.ts), split/merge (split-merge.test.ts), all-operations integration (integration.test.ts), library primitives (paragraph-edit.test.ts), and the raw-XML/part editors (raw.test.ts).pnpm lint(0),pnpm format:check(clean),pnpm typecheck+ editortsc(clean),pnpm --filter word-kit-site check(svelte-check 0 errors).validate() == 0.Breaking changes
None. All changes are additive (new package + new exports).
Checklist
🤖 Generated with Claude Code