Repository navigation
fix(editor): prevent empty Markdoc placeholder from breaking IME composition - #1682
Open
MilindChatrabhuji wants to merge 1 commit into
Open
MilindChatrabhuji wants to merge 1 commit into
MilindChatrabhuji wants to merge 1 commit into
Conversation
…S node decoration (Thinkmill#1616)
This branch has not been deployed
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.
Fixes #1616
Summary
placeholderPluginin the Markdoc ProseMirror editor fromDecoration.widget(1, <span>)toDecoration.node(0, doc.firstChild.nodeSize, { class: classes.placeholder, 'data-placeholder': text }), and render the placeholder text via CSS::beforewithcontent: attr(data-placeholder)inutils.ts.<span class="ProseMirror-placeholder">child DOM node inside the composing<p>element while IME composition was active, breaking Chrome/Firefox Japanese IME first-character composition.viewRef.current.updateState(state)inuseEditorView(editor-view.tsx) withviewRef.current.state !== stateso React's post-dispatch re-render does not redundantly re-run ProseMirrorupdateStatefor the state instance just applied indispatchTransaction.packages/keystatic/src/form/fields/markdoc/editor/tests/placeholder-ime.test.tsxverifying:<span>is inserted or removed during first-character composition on an empty editor, and placeholder attributes appear/disappear cleanly across empty/non-empty transitions.EditorView.prototype.updateStateis called once per transaction rather than twice on React re-render.@keystatic/corepatch changeset in.changeset/markdoc-placeholder-ime.md.Verification
vitest run --maxWorkers=1 --testTimeout=15000 packages/keystatic/src/form/fields/markdoc/editor/tests/: 18 test files passed (316 passed, 5 skipped pre-existing skipped/todo cases).tsc --noEmit: 0 errors across the workspace.eslintandprettier --checkon all modified/added files: passed.