Skip to content

fix: copy Unicode when selecting a GurbaniLipi pankti - #1884

Open
radiator13 wants to merge 3 commits into
KhalisFoundation:devfrom
radiator13:fix/1802-copy-unicode-pankti
Open

fix: copy Unicode when selecting a GurbaniLipi pankti#1884
radiator13 wants to merge 3 commits into
KhalisFoundation:devfrom
radiator13:fix/1802-copy-unicode-pankti

Conversation

@radiator13

Copy link
Copy Markdown

Fixes #1802

Problem

The copy-icon copied Unicode. Selecting a pankti and pressing Ctrl/Cmd+C copied ASCII/GurbaniLipi.

Cause

With Unicode display off, the DOM text is GurbaniLipi. Native copy uses that text.

Change

  • Store each line's unicode on data-unicode-verse
  • On copy from a .gurlipi / .gurlipi-reading-mode line, write that unicode to the clipboard
  • Leave Unicode-mode copies and translation copies unchanged

Test

  1. Open a shabad with Unicode display off
  2. Select a pankti and press Ctrl/Cmd+C
  3. Paste — it should be Gurmukhi Unicode, not ASCII

The copy-icon path already used verse.unicode. Selecting a line and
pressing Ctrl/Cmd+C copied the on-screen ASCII/GurbaniLipi glyphs.

On native copy from a gurlipi line, put that pankti's unicode on the
clipboard instead.

Fixes KhalisFoundation#1802
Native copy only inspected the selection anchor. A reverse selection
could miss the pankti. Also write through nativeEvent.clipboardData or
navigator.clipboard when clipboardData is missing.

Fixes KhalisFoundation#1802
- Join every selected pankti's unicode in document order instead of
  copying only the anchor line (KhalisFoundation#1802)
- Leave collapsed/empty selections to the native copy
- Fall back to native copy unless the selection touches GurbaniLipi
- Extend unit tests for all three cases
@radiator13

Copy link
Copy Markdown
Author

Follow-up commit 2d80661 hardens the copy interception around edge cases:

  • Multi-pankti selections now join every selected line's unicode (document order, de-duplicated) instead of copying only the anchor line.
  • Collapsed / empty selections no longer hijack Ctrl+C — native behaviour preserved.
  • Mixed or non-GurbaniLipi selections fall back to the native copy unless the selection starts or ends inside a .gurlipi / .gurlipi-reading-mode line (translations-only copies untouched).
  • Util signature simplified to getUnicodeCopyText({ unicodeMode, selection }); unit tests extended to cover all of the above (verified passing against jsdom).

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.

When copying a pankti, it should always copy the unicode text

1 participant