Remove jQuery from copy_as_gfm behavior

What does this MR do and why?

Drops the remaining jQuery usage from app/assets/javascripts/behaviors/markdown/copy_as_gfm.js. The three $(document).on(event, selector, handler) delegated registrations become native document.addEventListener calls, with a small delegatedTarget helper that walks up from a potential Text-node e.target and runs closest(selector) — matching jQuery's delegation semantics while supporting selection events whose target is a Text node. The two e.originalEvent.clipboardData unwraps become plain e.clipboardData, since native clipboard events expose that property directly.

CopyAsGFM.copyAsGFM now takes the delegated target as an explicit second argument. In jQuery delegation e.currentTarget is the matched selector element, but in native delegation e.currentTarget is always document, so the matched element needs to be threaded through explicitly — transformCodeSelection uses it to detect which side (left-side / right-side) of a diff a selection came from.

References

Closes #595359

How to set up and validate locally

Run the Jest spec for the changed behavior:

yarn jest spec/frontend/behaviors/copy_as_gfm_spec.js

All 13 tests should pass. The :js feature spec spec/features/markdown/copy_as_gfm_spec.rb runs on CI and exercises the full copy/paste flow against rendered markdown.

MR acceptance checklist

  • Tests added for new/changed behavior
  • All tests passing
  • Follows project style guide
  • No breaking changes introduced
  • Documentation updated (if applicable)

No new specs added — this is a behavior-preserving refactor. The existing spec/frontend/behaviors/copy_as_gfm_spec.js was updated to match the new copyAsGFM(e, target, transformer) signature and to drop originalEvent wrapping from the event mocks. ESLint and Prettier are clean.

Merge request reports

Loading