diff --git a/znai-docs/znai/release-notes/1.83/fix-2025-11-16-llm-text-selection-triple-click.md b/znai-docs/znai/release-notes/1.83/fix-2025-11-16-llm-text-selection-triple-click.md new file mode 100644 index 000000000..978698992 --- /dev/null +++ b/znai-docs/znai/release-notes/1.83/fix-2025-11-16-llm-text-selection-triple-click.md @@ -0,0 +1 @@ +* Fix: Ask In Slack and Generate Link are now working for paragraphs selected with triple click \ No newline at end of file diff --git a/znai-reactjs/src/doc-elements/text-selection/TextSelectionMenu.tsx b/znai-reactjs/src/doc-elements/text-selection/TextSelectionMenu.tsx index bc89a54ae..6fc1f69b2 100644 --- a/znai-reactjs/src/doc-elements/text-selection/TextSelectionMenu.tsx +++ b/znai-reactjs/src/doc-elements/text-selection/TextSelectionMenu.tsx @@ -219,6 +219,16 @@ export function TextSelectionMenu({ containerNode }: { containerNode: HTMLDivEle question: comment, context: panelData?.context || "", }); + + // Check if clipboard API is available + if (!navigator.clipboard || !navigator.clipboard.writeText) { + setNotification({ + type: "error", + message: "Clipboard API not available. Link: " + pageUrl, + }); + return; + } + try { await navigator.clipboard.writeText(pageUrl); setNotification({ type: "success", message: "Link is generated and copied to clipboard" }); diff --git a/znai-reactjs/src/doc-elements/text-selection/selectionUtils.js b/znai-reactjs/src/doc-elements/text-selection/selectionUtils.js index 36bf1ec42..ca0d923aa 100644 --- a/znai-reactjs/src/doc-elements/text-selection/selectionUtils.js +++ b/znai-reactjs/src/doc-elements/text-selection/selectionUtils.js @@ -14,23 +14,185 @@ * limitations under the License. */ +/** + * Normalizes element node boundaries to text nodes. + * + * Triple-click selections often use element nodes as boundaries (e.g.,

at offset 0). + * We need text nodes with character offsets to extract text accurately. + * + * Element offset N means "between child N-1 and child N": + *

offset=0 → before first child + *

offset=1 → after first child + * + * Examples: + * Triple-click

: (

, 0) to (

, 1) → normalize to text node boundaries + * Triple-click

  • : (