From e38505fc2df2f5fdc00e263dc1e1fe69a57ee3f6 Mon Sep 17 00:00:00 2001 From: MykolaGolubyev Date: Tue, 26 Aug 2025 20:51:11 -0400 Subject: [PATCH 1/2] slack: fix url built and bubble slash --- ...fix-2025-08-26-ask-slack-url-with-slash.md | 1 + ...x-2025-08-26-remove-ask-in-slack-bubble.md | 1 + znai-docs/znai/release-notes/2025.md | 4 +++ .../text-selection/HighlightUrlText.tsx | 28 +++++++++++++++---- .../text-selection/TextSelectionMenu.tsx | 4 +-- .../text-selection/highlightUrl.ts | 10 +++++-- 6 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 znai-docs/znai/release-notes/1.78.1/fix-2025-08-26-ask-slack-url-with-slash.md create mode 100644 znai-docs/znai/release-notes/1.78.1/fix-2025-08-26-remove-ask-in-slack-bubble.md diff --git a/znai-docs/znai/release-notes/1.78.1/fix-2025-08-26-ask-slack-url-with-slash.md b/znai-docs/znai/release-notes/1.78.1/fix-2025-08-26-ask-slack-url-with-slash.md new file mode 100644 index 000000000..d995fc58c --- /dev/null +++ b/znai-docs/znai/release-notes/1.78.1/fix-2025-08-26-ask-slack-url-with-slash.md @@ -0,0 +1 @@ +* Fix: Add forward slash in generated url for ask-in-slack \ No newline at end of file diff --git a/znai-docs/znai/release-notes/1.78.1/fix-2025-08-26-remove-ask-in-slack-bubble.md b/znai-docs/znai/release-notes/1.78.1/fix-2025-08-26-remove-ask-in-slack-bubble.md new file mode 100644 index 000000000..5508f6829 --- /dev/null +++ b/znai-docs/znai/release-notes/1.78.1/fix-2025-08-26-remove-ask-in-slack-bubble.md @@ -0,0 +1 @@ +* Fix: Remove ask-in-slack bubble on page navigation \ No newline at end of file diff --git a/znai-docs/znai/release-notes/2025.md b/znai-docs/znai/release-notes/2025.md index 637f46b1d..de56fc44d 100644 --- a/znai-docs/znai/release-notes/2025.md +++ b/znai-docs/znai/release-notes/2025.md @@ -1,3 +1,7 @@ +# 1.78.1 + +:include-markdowns: 1.78.1 + # 1.78 :include-markdowns: 1.78 diff --git a/znai-reactjs/src/doc-elements/text-selection/HighlightUrlText.tsx b/znai-reactjs/src/doc-elements/text-selection/HighlightUrlText.tsx index 9c34d58ca..baa15ae26 100644 --- a/znai-reactjs/src/doc-elements/text-selection/HighlightUrlText.tsx +++ b/znai-reactjs/src/doc-elements/text-selection/HighlightUrlText.tsx @@ -18,16 +18,18 @@ import { useEffect, useRef } from "react"; import { TextHighlighter } from "./textHighlihter"; import { mainPanelClassName } from "../../layout/classNames"; import { extractHighlightParams } from "./highlightUrl"; +import { documentationNavigation } from "../../structure/DocumentationNavigation"; import "./HighlightUrlText.css"; export function HighlightUrlText({ containerNode }: { containerNode: HTMLDivElement }) { const bubbleRef = useRef(null); useEffect(() => { const params = extractHighlightParams(); + let highlighter: TextHighlighter | null = null; if (params) { const container = document.querySelector(mainPanelClassName) || document.body; - const highlighter = new TextHighlighter(container); + highlighter = new TextHighlighter(container); const highlights = highlighter.highlight(params.selection, params.prefix, params.suffix); const firstHighlightedElement = highlights[0]; if (!firstHighlightedElement) { @@ -42,14 +44,16 @@ export function HighlightUrlText({ containerNode }: { containerNode: HTMLDivElem range.setEnd(highlights[highlights.length - 1], highlights[highlights.length - 1].childNodes.length); const selectionRect = range.getBoundingClientRect(); + const bubbleText = params.question.endsWith("/") + ? params.question.substring(0, params.question.length - 1) + : params.question; const bubble = bubbleRef.current; - bubble.innerText = params.question; + bubble.innerText = bubbleText; bubble.style.display = "block"; - - // Measure bubble dimensions after setting content + const bubbleRect = bubble.getBoundingClientRect(); const bubbleWidth = bubbleRect.width; - + const top = selectionRect.top - containerRect.top + containerNode.scrollTop - 60; const selectionCenter = selectionRect.left + selectionRect.width / 2.0; const left = selectionCenter - bubbleWidth / 2.0 - containerRect.left; @@ -64,6 +68,20 @@ export function HighlightUrlText({ containerNode }: { containerNode: HTMLDivElem } }, 100); } + + const urlChangeListener = () => { + if (bubbleRef.current) { + bubbleRef.current.style.display = "none"; + } + if (highlighter) { + highlighter.clearHighlights(); + } + }; + + documentationNavigation.addUrlChangeListener(urlChangeListener); + return () => { + documentationNavigation.removeUrlChangeListener(urlChangeListener); + }; }, []); return
; diff --git a/znai-reactjs/src/doc-elements/text-selection/TextSelectionMenu.tsx b/znai-reactjs/src/doc-elements/text-selection/TextSelectionMenu.tsx index a8821b746..d9b2e5712 100644 --- a/znai-reactjs/src/doc-elements/text-selection/TextSelectionMenu.tsx +++ b/znai-reactjs/src/doc-elements/text-selection/TextSelectionMenu.tsx @@ -197,7 +197,7 @@ export function TextSelectionMenu({ containerNode }: { containerNode: HTMLDivEle async function generateLink() { const comment = linkCommentInputRef.current?.value?.trim(); - const pageUrl = buildHighlightUrl(location.toString(), panelData!.prefixSuffixMatch, comment); + const pageUrl = buildHighlightUrl(panelData!.prefixSuffixMatch, comment); try { await navigator.clipboard.writeText(pageUrl); setNotification({ type: "success", message: "Link is generated and copied to clipboard" }); @@ -213,7 +213,7 @@ export function TextSelectionMenu({ containerNode }: { containerNode: HTMLDivEle return; } - const pageUrl = buildHighlightUrl(location.toString(), panelData!.prefixSuffixMatch, question); + const pageUrl = buildHighlightUrl(panelData!.prefixSuffixMatch, question); const body = { selectedText: panelData!.prefixSuffixMatch.selection, diff --git a/znai-reactjs/src/doc-elements/text-selection/highlightUrl.ts b/znai-reactjs/src/doc-elements/text-selection/highlightUrl.ts index c6a5f9e4c..4b8ea95c9 100644 --- a/znai-reactjs/src/doc-elements/text-selection/highlightUrl.ts +++ b/znai-reactjs/src/doc-elements/text-selection/highlightUrl.ts @@ -45,13 +45,19 @@ export function extractHighlightParams(): HighlightParams | null { return null; } -export function buildHighlightUrl(baseUrl: string, params: HighlightParams, question?: string): string { - const url = new URL(baseUrl); +export function buildHighlightUrl(params: HighlightParams, question?: string): string { + let builtUrl = location.origin + location.pathname; + if (!builtUrl.endsWith("/")) { + builtUrl += "/"; + } + + const url = new URL(builtUrl); url.searchParams.set(HIGHLIGHT_PREFIX_PARAM, encodeURIComponent(params.prefix)); url.searchParams.set(HIGHLIGHT_SELECTION_PARAM, encodeURIComponent(params.selection)); url.searchParams.set(HIGHLIGHT_SUFFIX_PARAM, encodeURIComponent(params.suffix)); if (question) { url.searchParams.set(HIGHLIGHT_QUESTION_PARAM, encodeURIComponent(question)); } + return url.toString(); } From 1e1a8f36002dd4825907ef4f9cfecf3e3d77e6d0 Mon Sep 17 00:00:00 2001 From: MykolaGolubyev Date: Tue, 26 Aug 2025 20:53:15 -0400 Subject: [PATCH 2/2] slack: fix url built and bubble slash --- .../1.78.1/fix-2025-08-26-remove-ask-in-slack-content-type.md | 1 + .../src/doc-elements/text-selection/TextSelectionMenu.tsx | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) create mode 100644 znai-docs/znai/release-notes/1.78.1/fix-2025-08-26-remove-ask-in-slack-content-type.md diff --git a/znai-docs/znai/release-notes/1.78.1/fix-2025-08-26-remove-ask-in-slack-content-type.md b/znai-docs/znai/release-notes/1.78.1/fix-2025-08-26-remove-ask-in-slack-content-type.md new file mode 100644 index 000000000..c6009a432 --- /dev/null +++ b/znai-docs/znai/release-notes/1.78.1/fix-2025-08-26-remove-ask-in-slack-content-type.md @@ -0,0 +1 @@ +* Fix: Remove ask-in-slack `content-type` from `POST` request to simplify CORS \ 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 d9b2e5712..374939334 100644 --- a/znai-reactjs/src/doc-elements/text-selection/TextSelectionMenu.tsx +++ b/znai-reactjs/src/doc-elements/text-selection/TextSelectionMenu.tsx @@ -227,9 +227,6 @@ export function TextSelectionMenu({ containerNode }: { containerNode: HTMLDivEle try { const response = await fetch(getDocMeta().sendToSlackUrl!, { method: "POST", - headers: { - "Content-Type": "application/json", - }, credentials: "include", body: JSON.stringify(body), });