Skip to content

fix: prevent unstyled lines and theme corruption in inline edit mode#68

Open
MageByte-Zero wants to merge 1 commit into
zarazhangrui:mainfrom
MageByte-Zero:fix/inline-edit-enter-paste
Open

fix: prevent unstyled lines and theme corruption in inline edit mode#68
MageByte-Zero wants to merge 1 commit into
zarazhangrui:mainfrom
MageByte-Zero:fix/inline-edit-enter-paste

Conversation

@MageByte-Zero

Copy link
Copy Markdown

Problem

Two bugs affect the inline editing mode (issue #49):

  1. Enter key inserts unstyled <div> — Chrome's default contenteditable behavior on Enter is to insert a <div>. This div inherits none of the element's CSS (font, color, line-height). The new line renders plain, looking completely different from the rest of the slide.

  2. Paste injects foreign styles — Pasting from a browser, doc editor, or another tab injects inline style attributes with foreign fonts and colors. The pasted text permanently overrides the theme until the user manually removes the styles.

Both issues reproduce every time a user edits text in the generated presentation.

Closes #49.

Fix

Three guards added to the inline editing section:

  1. document.execCommand('defaultParagraphSeparator', false, 'br') — changes the default separator
  2. keydown handler that intercepts Enter and calls insertLineBreak instead
  3. paste handler that strips to plain text via clipboardData.getData('text/plain')

Existing PRs

No open PR addresses this. Issue #49 has been open since 2026-04-11 with no fix submitted.

Pressing Enter in contenteditable inserts a <div> (Chrome default)
that inherits no theme styles — new line renders plain. Pasting rich
text injects foreign fonts/colors that break the presentation theme.

Add three guards: defaultParagraphSeparator='br', Enter intercept that
calls insertLineBreak, and paste handler that strips to plain text.
Closes zarazhangrui#49.
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.

Inline edit mode breaks font inheritance on Enter / paste — shows only after export + reload

1 participant