Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ff708abf6cdbca9586609ec7984ac3a997f7a20c
      
https://github.com/WebKit/WebKit/commit/ff708abf6cdbca9586609ec7984ac3a997f7a20c
  Author: Jessica Cheung <[email protected]>
  Date:   2026-05-08 (Fri, 08 May 2026)

  Changed paths:
    M Source/WebCore/editing/InsertTextCommand.cpp
    M Source/WebCore/editing/InsertTextCommand.h
    M Source/WebCore/editing/TypingCommand.cpp
    M Tools/TestWebKitAPI/Helpers/cocoa/SmartListsSupport.swift
    M Tools/TestWebKitAPI/Helpers/cocoa/WebPage+Extras.swift
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/SmartLists.mm

  Log Message:
  -----------
  [Smart Lists] Going into list format while composing mail does not keep style
https://bugs.webkit.org/show_bug.cgi?id=314170
rdar://175551917

Reviewed by Richard Robinson and Abrar Rahman Protyasha.

Smart Lists does not have logic to preserve the styling of the
text before creating the list. This means if the original text
is styled (such as <b>1. </b>), triggering smart list will remove
this from the DOM and an empty <li> is created without the styling.

So, in InsertTextCommand::applySmartListsIfNeeded() before any
alterations, get the editing style from the DOM node before it gets
deleted.

Then when the list item is created and the original marker is deleted,
call prepareToApplyAt to get the remaining styles that are not part of
the new <li>. Set the preserved style so the next time a character is
typed, it reads from document().selection().typingStyle() and gets the
style from before.

Note that this has to be set after typingAddedToOpenCommand, which calls
appliedEditing, because appliedEditing clears typing style.

Also, add testing support for recognizing bold, italics, and underline
in the SmartLists API tests. Write an API test for this change and
verify the styling is preserved.

* Source/WebCore/editing/InsertTextCommand.cpp:
(WebCore::InsertTextCommand::applySmartListsIfNeeded):
* Source/WebCore/editing/InsertTextCommand.h:
* Source/WebCore/editing/TypingCommand.cpp:
(WebCore::TypingCommand::insertTextRunWithoutNewlines):
* Tools/TestWebKitAPI/Helpers/cocoa/SmartListsSupport.swift:
(SmartListsSupport.processConfiguration(_:)):
* Tools/TestWebKitAPI/Helpers/cocoa/WebPage+Extras.swift:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/SmartLists.mm:
((SmartLists, ListPreservesTypingStyle)):

Canonical link: https://commits.webkit.org/312887@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to