From d8a526a64227b7322efecde19e8accda6cab286a Mon Sep 17 00:00:00 2001 From: MykolaGolubyev Date: Mon, 8 Sep 2025 19:53:39 -0400 Subject: [PATCH] slack: remove trailing slash from `questionId` --- ...d-2025-09-07-jupyter-table-style-tweaks.md | 2 +- ...-2025-09-08-ask-in-slack-trailing-slash.md | 1 + .../text-selection/HighlightedText.css | 16 +++++++++++++ .../text-selection/HighlightedText.tsx | 19 ++++++++++++++- .../text-selection/ResolveQuestionButton.css | 16 +++++++++++++ .../text-selection/ResolveQuestionButton.tsx | 16 +++++++++++++ .../text-selection/SlackActiveQuestions.css | 16 +++++++++++++ .../text-selection/SlackActiveQuestions.tsx | 21 ++++++++++++++++- .../text-selection/queryParamUtils.ts | 23 +++++++++++++++++++ .../text-selection/textHighlighter.css | 16 +++++++++++++ 10 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 znai-docs/znai/release-notes/1.80/fix-2025-09-08-ask-in-slack-trailing-slash.md create mode 100644 znai-reactjs/src/doc-elements/text-selection/queryParamUtils.ts diff --git a/znai-docs/znai/release-notes/1.79/add-2025-09-07-jupyter-table-style-tweaks.md b/znai-docs/znai/release-notes/1.79/add-2025-09-07-jupyter-table-style-tweaks.md index e5f2b3591..e5a0b6c4c 100644 --- a/znai-docs/znai/release-notes/1.79/add-2025-09-07-jupyter-table-style-tweaks.md +++ b/znai-docs/znai/release-notes/1.79/add-2025-09-07-jupyter-table-style-tweaks.md @@ -1 +1 @@ -* Add: Jupyter notebook table output style tweaks \ No newline at end of file +* Fix: Slack link - remove trailing slash from `questionId` to fix auto scroll to the question \ No newline at end of file diff --git a/znai-docs/znai/release-notes/1.80/fix-2025-09-08-ask-in-slack-trailing-slash.md b/znai-docs/znai/release-notes/1.80/fix-2025-09-08-ask-in-slack-trailing-slash.md new file mode 100644 index 000000000..a7977ce8d --- /dev/null +++ b/znai-docs/znai/release-notes/1.80/fix-2025-09-08-ask-in-slack-trailing-slash.md @@ -0,0 +1 @@ +* Fix: [Jupyter](snippets/jupyter-notebook) `includeSection` to handle section delimiter that has other text below it \ No newline at end of file diff --git a/znai-reactjs/src/doc-elements/text-selection/HighlightedText.css b/znai-reactjs/src/doc-elements/text-selection/HighlightedText.css index 5ea3c4427..35ce75412 100644 --- a/znai-reactjs/src/doc-elements/text-selection/HighlightedText.css +++ b/znai-reactjs/src/doc-elements/text-selection/HighlightedText.css @@ -1,3 +1,19 @@ +/* + * Copyright 2025 znai maintainers + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + .znai-highlight-question-bubble { display: none; position: absolute; diff --git a/znai-reactjs/src/doc-elements/text-selection/HighlightedText.tsx b/znai-reactjs/src/doc-elements/text-selection/HighlightedText.tsx index 8b35273d2..6f2e6d465 100644 --- a/znai-reactjs/src/doc-elements/text-selection/HighlightedText.tsx +++ b/znai-reactjs/src/doc-elements/text-selection/HighlightedText.tsx @@ -1,3 +1,19 @@ +/* + * Copyright 2025 znai maintainers + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import React, { useEffect, useRef, useState } from "react"; import { TextHighlighter } from "./textHighlighter"; @@ -7,6 +23,7 @@ import { createPortal } from "react-dom"; import { afterTitleId } from "../../layout/classNamesAndIds"; import "./HighlightedText.css"; +import { removeTrailingSlashFromQueryParam } from "./queryParamUtils"; interface Props { containerNode: HTMLDivElement; @@ -29,7 +46,7 @@ export function HighlightedText({ displayBubbleAndScrollIntoView, additionalView, }: Props) { - const cleanedUpQuestion = question.endsWith("/") ? question.substring(0, question.length - 1) : question; + const cleanedUpQuestion = removeTrailingSlashFromQueryParam(question); const bubbleRef = useRef(null); const detachedQuestionRef = useRef(null); diff --git a/znai-reactjs/src/doc-elements/text-selection/ResolveQuestionButton.css b/znai-reactjs/src/doc-elements/text-selection/ResolveQuestionButton.css index 53984311c..ffb6a6462 100644 --- a/znai-reactjs/src/doc-elements/text-selection/ResolveQuestionButton.css +++ b/znai-reactjs/src/doc-elements/text-selection/ResolveQuestionButton.css @@ -1,3 +1,19 @@ +/* + * Copyright 2025 znai maintainers + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + .resolve-question-button { background: none; border: none; diff --git a/znai-reactjs/src/doc-elements/text-selection/ResolveQuestionButton.tsx b/znai-reactjs/src/doc-elements/text-selection/ResolveQuestionButton.tsx index b9c248c0c..b777f73b8 100644 --- a/znai-reactjs/src/doc-elements/text-selection/ResolveQuestionButton.tsx +++ b/znai-reactjs/src/doc-elements/text-selection/ResolveQuestionButton.tsx @@ -1,3 +1,19 @@ +/* + * Copyright 2025 znai maintainers + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import React, { useState, useEffect, useRef } from "react"; import "./ResolveQuestionButton.css"; diff --git a/znai-reactjs/src/doc-elements/text-selection/SlackActiveQuestions.css b/znai-reactjs/src/doc-elements/text-selection/SlackActiveQuestions.css index 1bf7ee483..33539a156 100644 --- a/znai-reactjs/src/doc-elements/text-selection/SlackActiveQuestions.css +++ b/znai-reactjs/src/doc-elements/text-selection/SlackActiveQuestions.css @@ -1,3 +1,19 @@ +/* + * Copyright 2025 znai maintainers + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + .znai-highlight-bubble-resolve-and-link { display: flex; align-items: center; diff --git a/znai-reactjs/src/doc-elements/text-selection/SlackActiveQuestions.tsx b/znai-reactjs/src/doc-elements/text-selection/SlackActiveQuestions.tsx index b415ed964..60c7b53b3 100644 --- a/znai-reactjs/src/doc-elements/text-selection/SlackActiveQuestions.tsx +++ b/znai-reactjs/src/doc-elements/text-selection/SlackActiveQuestions.tsx @@ -1,3 +1,19 @@ +/* + * Copyright 2025 znai maintainers + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import React, { useEffect, useState } from "react"; import { currentPageId, pageIdFromTocItem } from "../../structure/DocumentationNavigation"; import { getDocMeta } from "../../structure/docMeta"; @@ -7,6 +23,7 @@ import { TocItem } from "../../structure/TocItem"; import { ResolveQuestionButton } from "./ResolveQuestionButton"; import "./SlackActiveQuestions.css"; +import { removeTrailingSlashFromQueryParam } from "./queryParamUtils"; interface Question { id: string; @@ -113,6 +130,8 @@ export function SlackActiveQuestions({ containerNode, tocItem }: { containerNode ); + const cleanedUpQuestionId = removeTrailingSlashFromQueryParam(questionId); + return ( ); }); diff --git a/znai-reactjs/src/doc-elements/text-selection/queryParamUtils.ts b/znai-reactjs/src/doc-elements/text-selection/queryParamUtils.ts new file mode 100644 index 000000000..06e862e30 --- /dev/null +++ b/znai-reactjs/src/doc-elements/text-selection/queryParamUtils.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2025 znai maintainers + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function removeTrailingSlashFromQueryParam(value: string | undefined) { + if (!value) { + return value; + } + + return value.endsWith("/") ? value.substring(0, value.length - 1) : value; +} diff --git a/znai-reactjs/src/doc-elements/text-selection/textHighlighter.css b/znai-reactjs/src/doc-elements/text-selection/textHighlighter.css index e75f74dff..65ca67217 100644 --- a/znai-reactjs/src/doc-elements/text-selection/textHighlighter.css +++ b/znai-reactjs/src/doc-elements/text-selection/textHighlighter.css @@ -1,3 +1,19 @@ +/* + * Copyright 2025 znai maintainers + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + .znai-highlight { background-color: #ffeb3b; color: black;