forked from akai/readest
This commit is contained in:
@@ -54,7 +54,7 @@ export function useTextTranslation(
|
||||
if (!view || !enabled.current) return;
|
||||
const observer = createTranslationObserver();
|
||||
observerRef.current = observer;
|
||||
const nodes = walkTextNodes(view);
|
||||
const nodes = walkTextNodes(view, ['pre', 'code', 'math']);
|
||||
console.log('Observing text nodes for translation:', nodes.length);
|
||||
allTextNodes.current = nodes;
|
||||
nodes.forEach((el) => observer.observe(el));
|
||||
|
||||
@@ -337,8 +337,8 @@ foliate-view {
|
||||
.book-spine {
|
||||
background-image:
|
||||
linear-gradient(180deg,
|
||||
hsla(0, 0%, 90%, 0.2) 0%, /* Top highlight */
|
||||
hsla(0, 0%, 85%, 0.15) 0.5%, /* Top highlight */
|
||||
hsla(0, 0%, 95%, 0.2) 0%, /* Top highlight */
|
||||
hsla(0, 0%, 90%, 0.1) 1%, /* Top highlight */
|
||||
transparent 2%, /* Main book surface */
|
||||
transparent 50%, /* Main book surface */
|
||||
hsla(0, 0%, 25%, 0.15) 95%, /* Bottom shadow */
|
||||
@@ -348,7 +348,7 @@ foliate-view {
|
||||
hsla(0, 0%, 0%, 0.1) 0%, /* Left binding shadow */
|
||||
hsla(0, 0%, 20%, 0.2) 0.5%, /* Dark transition */
|
||||
hsla(0, 0%, 95%, 0.4) 0.8%, /* Peak highlight */
|
||||
hsla(0, 0%, 90%, 0.4) 1.8%, /* Peak highlight */
|
||||
hsla(0, 0%, 85%, 0.4) 2.0%, /* Peak highlight */
|
||||
hsla(0, 0%, 60%, 0.3) 2.8%, /* Gradient highlight */
|
||||
hsla(0, 0%, 40%, 0.2) 4.2%, /* Shadow between highlights */
|
||||
hsla(0, 0%, 70%, 0.15) 4.6%, /* Second peak highlight */
|
||||
@@ -362,6 +362,6 @@ foliate-view {
|
||||
mask: linear-gradient(180deg,
|
||||
black 0%,
|
||||
rgba(0,0,0,0.9) 50%,
|
||||
rgba(0,0,0,0.7) 100%
|
||||
rgba(0,0,0,0.5) 100%
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const walkTextNodes = (root: HTMLElement): HTMLElement[] => {
|
||||
export const walkTextNodes = (root: HTMLElement, rejectTags: string[] = []): HTMLElement[] => {
|
||||
const elements: HTMLElement[] = [];
|
||||
const walk = (node: HTMLElement | Document | ShadowRoot, depth = 0) => {
|
||||
if (depth > 15) return;
|
||||
@@ -7,7 +7,11 @@ export const walkTextNodes = (root: HTMLElement): HTMLElement[] => {
|
||||
}
|
||||
const children = 'children' in node ? (Array.from(node.children) as HTMLElement[]) : [];
|
||||
for (const child of children) {
|
||||
if (child.tagName === 'STYLE' || child.tagName === 'LINK') {
|
||||
if (
|
||||
child.tagName === 'STYLE' ||
|
||||
child.tagName === 'LINK' ||
|
||||
rejectTags.includes(child.tagName.toLowerCase())
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (child.shadowRoot) {
|
||||
|
||||
Reference in New Issue
Block a user