WebCore implements custom paste behavior for Paste as Quotation, which is triggered by the presence of a specific class attribute value on the blockquote element being pasted (see isMailPasteAsQuotationNode in ReplaceSeelctionCommand.cpp). This allows clients of the legacy API to create a document fragment that will get pasted as a quotation. To expose the same functionality to clients of the modern WebKit API, we can introduce an explicit Paste as Quotation command, which will take care of creating an enclosing blockquote with the appropriate class. In the future we can do away with using the class attribute to signal the desired behavior altogether.
Created attachment 349400 [details] macOS-only patch to see what work needs to be done in other ports
Attachment 349400 [details] did not pass style-queue: ERROR: Source/WebCore/editing/mac/EditorMac.mm:114: Extra space before ) [whitespace/parens] [2] Total errors found: 1 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Created attachment 349426 [details] Multi-platform patch for EWS
Attachment 349426 [details] did not pass style-queue: ERROR: Source/WebCore/editing/mac/EditorMac.mm:97: Extra space before ) [whitespace/parens] [2] Total errors found: 1 in 12 files If any of these errors are false positives, please file a bug against check-webkit-style.
Created attachment 349432 [details] Multi-platform patch for EWS
Attachment 349432 [details] did not pass style-queue: ERROR: Source/WebCore/editing/mac/EditorMac.mm:97: Extra space before ) [whitespace/parens] [2] Total errors found: 1 in 12 files If any of these errors are false positives, please file a bug against check-webkit-style.
Created attachment 349436 [details] Multi-platform patch for EWS
Attachment 349436 [details] did not pass style-queue: ERROR: Source/WebCore/editing/mac/EditorMac.mm:97: Extra space before ) [whitespace/parens] [2] Total errors found: 1 in 12 files If any of these errors are false positives, please file a bug against check-webkit-style.
Created attachment 349454 [details] Multi-platform patch for EWS
Attachment 349454 [details] did not pass style-queue: ERROR: Source/WebCore/editing/mac/EditorMac.mm:97: Extra space before ) [whitespace/parens] [2] Total errors found: 1 in 14 files If any of these errors are false positives, please file a bug against check-webkit-style.
Created attachment 349574 [details] Add PasteAsQuotation command and -[WKWebView _pasteAsQuotation:]
Attachment 349574 [details] did not pass style-queue: ERROR: Source/WebCore/editing/mac/EditorMac.mm:96: Extra space before ) [whitespace/parens] [2] Total errors found: 1 in 25 files If any of these errors are false positives, please file a bug against check-webkit-style.
Comment on attachment 349574 [details] Add PasteAsQuotation command and -[WKWebView _pasteAsQuotation:] View in context: https://bugs.webkit.org/attachment.cgi?id=349574&action=review r=mews > Source/WebCore/editing/Editor.h:135 > + AsQuotation = 2 << 0, ‽‽‽‽ > LayoutTests/editing/pasteboard/4930986-1-paste-as-quotation.html:17 > +document.addEventListener("beforecopy", (event) => { event.preventDefault(); }); Nit - no need for the { } around the function body. > LayoutTests/editing/pasteboard/4930986-2-paste-as-quotation.html:13 > + document.addEventListener("beforecopy", (event) => { event.preventDefault(); }); (Ditto) > LayoutTests/editing/pasteboard/4930986-3-paste-as-quotation.html:17 > +document.addEventListener("beforecopy", (event) => { event.preventDefault(); }); (Ditto)
Comment on attachment 349574 [details] Add PasteAsQuotation command and -[WKWebView _pasteAsQuotation:] View in context: https://bugs.webkit.org/attachment.cgi?id=349574&action=review >> Source/WebCore/editing/Editor.h:135 >> + AsQuotation = 2 << 0, > > ‽‽‽‽ The whole thing is unbelievable. >> LayoutTests/editing/pasteboard/4930986-1-paste-as-quotation.html:17 >> +document.addEventListener("beforecopy", (event) => { event.preventDefault(); }); > > Nit - no need for the { } around the function body. Nice.
Committed <https://trac.webkit.org/r235955>.
<rdar://problem/44397322>