Merge pull request #4739 from RSSNext/sync/main-to-dev-20251120

Sync main branch to dev branch
This commit is contained in:
Stephen Zhou
2025-11-21 15:18:00 +08:00
committed by GitHub
4 changed files with 16 additions and 26 deletions
@@ -1,4 +1,4 @@
# What's new in v1.2.1
# What's new in v1.2
## Shiny new things
@@ -4,16 +4,7 @@ import { getAccentColorValue } from "@follow/shared/settings/constants"
import { hexToHslString } from "@follow/utils"
import { nanoid } from "nanoid"
import type { FC, PropsWithChildren, ReactNode } from "react"
import {
createContext,
createElement,
use,
useCallback,
useLayoutEffect,
useMemo,
useRef,
useState,
} from "react"
import { createContext, createElement, use, useLayoutEffect, useMemo, useState } from "react"
import root from "react-shadow"
import { useUISettingKeys } from "~/atoms/settings/ui"
@@ -87,15 +78,16 @@ export const ShadowDOM: FC<
injectHostStyles ? cloneStylesElement() : [],
)
const shadowRootRef = useRef<ShadowRoot | null>(null)
const [el, setEl] = useState<{ shadowRoot: ShadowRoot } | null>(null)
useLayoutEffect(() => {
if (!textSelectionEnabled || !shadowRootRef.current || !onTextSelect) return
if (!el) return
const { shadowRoot } = el
const cleanup = addTextSelectionListener(shadowRootRef.current, onTextSelect, onSelectionClear)
if (!textSelectionEnabled || !shadowRoot || !onTextSelect) return
return cleanup
}, [textSelectionEnabled, onTextSelect, onSelectionClear])
return addTextSelectionListener(shadowRoot, onTextSelect, onSelectionClear)
}, [textSelectionEnabled, onTextSelect, onSelectionClear, el])
useLayoutEffect(() => {
if (!injectHostStyles) return
@@ -123,14 +115,7 @@ export const ShadowDOM: FC<
return (
// @ts-expect-error
<root.div
{...rest}
ref={useCallback((element) => {
if (element) {
shadowRootRef.current = element.shadowRoot
}
}, [])}
>
<root.div {...rest} ref={setEl}>
<ShadowDOMContext value={true}>
<div
style={useMemo(
@@ -91,6 +91,10 @@ export const ArticleLayout: React.FC<EntryLayoutProps> = ({
handleSelectionClear()
}, [showTranscript, handleSelectionClear])
useEffect(() => {
handleSelectionClear()
}, [entryId, handleSelectionClear])
if (!entry) return null
return (
@@ -139,6 +143,7 @@ export const ArticleLayout: React.FC<EntryLayoutProps> = ({
)}
</ErrorBoundary>
</div>
<TextSelectionToolbar
selection={textSelection}
onRequestClose={handleSelectionClear}
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "Folo",
"type": "module",
"version": "1.2.1",
"version": "1.2.2",
"private": true,
"description": "Follow everything in one place",
"author": "Folo Team",
@@ -87,5 +87,5 @@
"vite-tsconfig-paths": "5.1.4"
},
"productName": "Folo",
"mainHash": "ddce11a91e6a16e28d193a7d4f0f211d2903d5e6d53193fc5fa7a9735c17f0e8"
"mainHash": "1c627eb0ea5a109a4fc2d7ac5a78777df546d831f6cced620b8120d41dc4e444"
}