mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 04:57:09 +03:00
fix more components
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import * as ReactDOM from "react-dom";
|
import { createRoot, Root } from 'react-dom/client';
|
||||||
import ChapterVoteComponent, { ChapterVoteState } from "../components/ChapterVoteComponent";
|
import ChapterVoteComponent, { ChapterVoteState } from "../components/ChapterVoteComponent";
|
||||||
import { VoteResponse } from "../messageTypes";
|
import { VoteResponse } from "../messageTypes";
|
||||||
import { Category, SegmentUUID, SponsorTime } from "../types";
|
import { Category, SegmentUUID, SponsorTime } from "../types";
|
||||||
@@ -7,6 +7,7 @@ import { Category, SegmentUUID, SponsorTime } from "../types";
|
|||||||
export class ChapterVote {
|
export class ChapterVote {
|
||||||
container: HTMLElement;
|
container: HTMLElement;
|
||||||
ref: React.RefObject<ChapterVoteComponent>;
|
ref: React.RefObject<ChapterVoteComponent>;
|
||||||
|
root: Root;
|
||||||
|
|
||||||
unsavedState: ChapterVoteState;
|
unsavedState: ChapterVoteState;
|
||||||
|
|
||||||
@@ -19,10 +20,8 @@ export class ChapterVote {
|
|||||||
this.container.id = "chapterVote";
|
this.container.id = "chapterVote";
|
||||||
this.container.style.height = "100%";
|
this.container.style.height = "100%";
|
||||||
|
|
||||||
ReactDOM.render(
|
this.root = createRoot(this.container);
|
||||||
<ChapterVoteComponent ref={this.ref} vote={vote} />,
|
this.root.render(<ChapterVoteComponent ref={this.ref} vote={vote} />);
|
||||||
this.container
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getContainer(): HTMLElement {
|
getContainer(): HTMLElement {
|
||||||
@@ -30,7 +29,7 @@ export class ChapterVote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
close(): void {
|
close(): void {
|
||||||
ReactDOM.unmountComponentAtNode(this.container);
|
this.root.unmount();
|
||||||
this.container.remove();
|
this.container.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import * as ReactDOM from "react-dom";
|
import { createRoot, Root } from 'react-dom/client';
|
||||||
import NoticeComponent from "../components/NoticeComponent";
|
import NoticeComponent from "../components/NoticeComponent";
|
||||||
|
|
||||||
import Utils from "../utils";
|
import Utils from "../utils";
|
||||||
@@ -35,6 +35,7 @@ export default class GenericNotice {
|
|||||||
noticeElement: HTMLDivElement;
|
noticeElement: HTMLDivElement;
|
||||||
noticeRef: React.MutableRefObject<NoticeComponent>;
|
noticeRef: React.MutableRefObject<NoticeComponent>;
|
||||||
idSuffix: string;
|
idSuffix: string;
|
||||||
|
root: Root;
|
||||||
|
|
||||||
constructor(contentContainer: ContentContainer, idSuffix: string, options: NoticeOptions) {
|
constructor(contentContainer: ContentContainer, idSuffix: string, options: NoticeOptions) {
|
||||||
this.noticeRef = React.createRef();
|
this.noticeRef = React.createRef();
|
||||||
@@ -49,11 +50,13 @@ export default class GenericNotice {
|
|||||||
|
|
||||||
referenceNode.prepend(this.noticeElement);
|
referenceNode.prepend(this.noticeElement);
|
||||||
|
|
||||||
this.update(options);
|
this.root = createRoot(this.noticeElement);
|
||||||
|
|
||||||
|
this.update(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
update(options: NoticeOptions): void {
|
update(options: NoticeOptions): void {
|
||||||
ReactDOM.render(
|
this.root.render(
|
||||||
<NoticeComponent
|
<NoticeComponent
|
||||||
noticeTitle={options.title}
|
noticeTitle={options.title}
|
||||||
idSuffix={this.idSuffix}
|
idSuffix={this.idSuffix}
|
||||||
@@ -92,8 +95,7 @@ export default class GenericNotice {
|
|||||||
</>
|
</>
|
||||||
: null}
|
: null}
|
||||||
|
|
||||||
</NoticeComponent>,
|
</NoticeComponent>
|
||||||
this.noticeElement
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +139,7 @@ export default class GenericNotice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
close(): void {
|
close(): void {
|
||||||
ReactDOM.unmountComponentAtNode(this.noticeElement);
|
this.root.unmount();
|
||||||
|
|
||||||
this.noticeElement.remove();
|
this.noticeElement.remove();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import * as ReactDOM from "react-dom";
|
import { createRoot, Root } from 'react-dom/client';
|
||||||
|
|
||||||
export interface RectangleTooltipProps {
|
export interface RectangleTooltipProps {
|
||||||
text: string,
|
text: string,
|
||||||
@@ -20,7 +20,7 @@ export interface RectangleTooltipProps {
|
|||||||
export class RectangleTooltip {
|
export class RectangleTooltip {
|
||||||
text: string;
|
text: string;
|
||||||
container: HTMLDivElement;
|
container: HTMLDivElement;
|
||||||
|
root: Root;
|
||||||
timer: NodeJS.Timeout;
|
timer: NodeJS.Timeout;
|
||||||
|
|
||||||
constructor(props: RectangleTooltipProps) {
|
constructor(props: RectangleTooltipProps) {
|
||||||
@@ -32,6 +32,7 @@ export class RectangleTooltip {
|
|||||||
this.text = props.text;
|
this.text = props.text;
|
||||||
props.fontSize ??= "10px";
|
props.fontSize ??= "10px";
|
||||||
|
|
||||||
|
|
||||||
this.container = document.createElement('div');
|
this.container = document.createElement('div');
|
||||||
props.htmlId ??= "sponsorRectangleTooltip" + props.text;
|
props.htmlId ??= "sponsorRectangleTooltip" + props.text;
|
||||||
this.container.id = props.htmlId;
|
this.container.id = props.htmlId;
|
||||||
@@ -47,7 +48,8 @@ export class RectangleTooltip {
|
|||||||
this.timer = setTimeout(() => this.close(), props.timeout * 1000);
|
this.timer = setTimeout(() => this.close(), props.timeout * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactDOM.render(
|
this.root = createRoot(this.container);
|
||||||
|
this.root.render(
|
||||||
<div style={{
|
<div style={{
|
||||||
bottom: props.bottomOffset,
|
bottom: props.bottomOffset,
|
||||||
left: props.leftOffset,
|
left: props.leftOffset,
|
||||||
@@ -81,13 +83,12 @@ export class RectangleTooltip {
|
|||||||
|
|
||||||
{chrome.i18n.getMessage("GotIt")}
|
{chrome.i18n.getMessage("GotIt")}
|
||||||
</button>
|
</button>
|
||||||
</div>,
|
</div>
|
||||||
this.container
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
close(): void {
|
close(): void {
|
||||||
ReactDOM.unmountComponentAtNode(this.container);
|
this.root.unmount();
|
||||||
this.container.remove();
|
this.container.remove();
|
||||||
|
|
||||||
if (this.timer) clearTimeout(this.timer);
|
if (this.timer) clearTimeout(this.timer);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import * as ReactDOM from "react-dom";
|
import { createRoot, Root } from 'react-dom/client';
|
||||||
|
|
||||||
import Utils from "../utils";
|
import Utils from "../utils";
|
||||||
const utils = new Utils();
|
const utils = new Utils();
|
||||||
@@ -17,6 +17,8 @@ class SubmissionNotice {
|
|||||||
|
|
||||||
noticeElement: HTMLDivElement;
|
noticeElement: HTMLDivElement;
|
||||||
|
|
||||||
|
root: Root;
|
||||||
|
|
||||||
constructor(contentContainer: ContentContainer, callback: () => unknown) {
|
constructor(contentContainer: ContentContainer, callback: () => unknown) {
|
||||||
this.noticeRef = React.createRef();
|
this.noticeRef = React.createRef();
|
||||||
|
|
||||||
@@ -30,13 +32,13 @@ class SubmissionNotice {
|
|||||||
|
|
||||||
referenceNode.prepend(this.noticeElement);
|
referenceNode.prepend(this.noticeElement);
|
||||||
|
|
||||||
ReactDOM.render(
|
this.root = createRoot(this.noticeElement);
|
||||||
|
this.root.render(
|
||||||
<SubmissionNoticeComponent
|
<SubmissionNoticeComponent
|
||||||
contentContainer={contentContainer}
|
contentContainer={contentContainer}
|
||||||
callback={callback}
|
callback={callback}
|
||||||
ref={this.noticeRef}
|
ref={this.noticeRef}
|
||||||
closeListener={() => this.close(false)} />,
|
closeListener={() => this.close(false)} />
|
||||||
this.noticeElement
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +48,7 @@ class SubmissionNotice {
|
|||||||
|
|
||||||
close(callRef = true): void {
|
close(callRef = true): void {
|
||||||
if (callRef) this.noticeRef.current.cancel();
|
if (callRef) this.noticeRef.current.cancel();
|
||||||
ReactDOM.unmountComponentAtNode(this.noticeElement);
|
this.root.unmount();
|
||||||
|
|
||||||
this.noticeElement.remove();
|
this.noticeElement.remove();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import * as ReactDOM from "react-dom";
|
import { createRoot, Root } from 'react-dom/client';
|
||||||
import { ButtonListener } from "../types";
|
import { ButtonListener } from "../types";
|
||||||
|
|
||||||
export interface TooltipProps {
|
export interface TooltipProps {
|
||||||
@@ -26,6 +26,7 @@ export class Tooltip {
|
|||||||
container: HTMLDivElement;
|
container: HTMLDivElement;
|
||||||
|
|
||||||
timer: NodeJS.Timeout;
|
timer: NodeJS.Timeout;
|
||||||
|
root: Root;
|
||||||
|
|
||||||
constructor(props: TooltipProps) {
|
constructor(props: TooltipProps) {
|
||||||
props.bottomOffset ??= "70px";
|
props.bottomOffset ??= "70px";
|
||||||
@@ -54,8 +55,9 @@ export class Tooltip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const backgroundColor = `rgba(28, 28, 28, ${props.opacity})`;
|
const backgroundColor = `rgba(28, 28, 28, ${props.opacity})`;
|
||||||
|
|
||||||
ReactDOM.render(
|
this.root = createRoot(this.container);
|
||||||
|
this.root.render(
|
||||||
<div style={{bottom: props.bottomOffset, left: props.leftOffset, right: props.rightOffset, backgroundColor}}
|
<div style={{bottom: props.bottomOffset, left: props.leftOffset, right: props.rightOffset, backgroundColor}}
|
||||||
className={"sponsorBlockTooltip" + (props.displayTriangle ? " sbTriangle" : "") + ` ${props.extraClass}`}>
|
className={"sponsorBlockTooltip" + (props.displayTriangle ? " sbTriangle" : "") + ` ${props.extraClass}`}>
|
||||||
<div>
|
<div>
|
||||||
@@ -93,8 +95,7 @@ export class Tooltip {
|
|||||||
{chrome.i18n.getMessage("GotIt")}
|
{chrome.i18n.getMessage("GotIt")}
|
||||||
</button>
|
</button>
|
||||||
: null}
|
: null}
|
||||||
</div>,
|
</div>
|
||||||
this.container
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ export class Tooltip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
close(): void {
|
close(): void {
|
||||||
ReactDOM.unmountComponentAtNode(this.container);
|
this.root.unmount();
|
||||||
this.container.remove();
|
this.container.remove();
|
||||||
|
|
||||||
if (this.timer) clearTimeout(this.timer);
|
if (this.timer) clearTimeout(this.timer);
|
||||||
|
|||||||
Reference in New Issue
Block a user