Загрузка данных
diff --git a/src/components/Toolbar/index.tsx b/src/components/Toolbar/index.tsx
index d8ef129..380df73 100644
--- a/src/components/Toolbar/index.tsx
+++ b/src/components/Toolbar/index.tsx
@@ -6,8 +6,6 @@ import { Dispatch, SetStateAction, useEffect, useRef, useState } from 'react';
import { Observable } from 'rxjs';
-import { Hotkeys, Keys } from '@core/Hotkeys';
-
import { MenuList } from '@src/components/Menu';
import SplitDropdown from '@src/components/SplitDropdown';
@@ -42,12 +40,11 @@ import styles from './index.module.scss';
interface ToolbarProps {
toggleDOM: () => void;
- addDrawing: (name: DrawingsNames) => Promise<void>;
+ addDrawing: (name: DrawingsNames) => void;
setEndlessDrawingsMode: (value: boolean) => void;
isEndlessDrawingsMode$: Observable<boolean>;
activateCrosshair: () => void;
activeTool$: Observable<ActiveDrawingTool>;
- hotkeys: Hotkeys;
}
const implemented = {
@@ -68,7 +65,6 @@ export default function Toolbar({
isEndlessDrawingsMode$,
activateCrosshair,
activeTool$,
- hotkeys,
}: ToolbarProps) {
const [selectedLineType, setSelectedLineType] = useState<DrawingsNames>(DrawingsNames.trendLine);
const [selectedMeasurementTool, setSelectedMeasurementTool] = useState(DrawingsNames.fixedRangeProfile);
@@ -81,9 +77,9 @@ export default function Toolbar({
const toolbarRef = useRef<HTMLDivElement | null>(null);
- const createDrawingHandler = (setter: Dispatch<SetStateAction<DrawingsNames>>) => async (value: DrawingsNames) => {
+ const createDrawingHandler = (setter: Dispatch<SetStateAction<DrawingsNames>>) => (value: DrawingsNames) => {
setter(value);
- await addDrawing(value);
+ addDrawing(value);
};
const findOptionByValue = <T extends { value: string }>(options: T[], selectedValue: T['value']): T | undefined =>
@@ -102,61 +98,28 @@ export default function Toolbar({
const getTooltipClassName = () => classNames(styles.tooltipHint, CHART_DRAWING_TOOLTIP);
useEffect(() => {
- const hashT = hotkeys.register({
- keys: [Keys.alt, Keys.t],
- callback: async () => {
- await createDrawingHandler(setSelectedLineType)(DrawingsNames.trendLine);
- },
- });
- const hashH = hotkeys.register({
- keys: [Keys.alt, Keys.h],
- callback: async () => {
- await createDrawingHandler(setSelectedLineType)(DrawingsNames.horizontalLine);
- },
- });
- const hashV = hotkeys.register({
- keys: [Keys.alt, Keys.v],
- callback: async () => {
- await createDrawingHandler(setSelectedLineType)(DrawingsNames.verticalLine);
- },
- });
- const hashF = hotkeys.register({
- keys: [Keys.alt, Keys.f],
- callback: async () => {
- await createDrawingHandler(setSelectedGannAndFibonacci)(DrawingsNames.fibonacciRetracement);
- },
- });
- // const hashShift = hotkeys.register({
- // keys: [Keys.shift],
- // pressHoldRequired: true,
- // callback: async () => {
- // await addDrawing(DrawingsNames.ruler);
- // },
- // });
-
- return () => {
- hotkeys.unregister({
- keys: [Keys.alt, Keys.t],
- hash: hashT,
- });
- hotkeys.unregister({
- keys: [Keys.alt, Keys.h],
- hash: hashH,
- });
- hotkeys.unregister({
- keys: [Keys.alt, Keys.v],
- hash: hashV,
- });
- hotkeys.unregister({
- keys: [Keys.alt, Keys.f],
- hash: hashF,
- });
- // hotkeys.unregister({
- // keys: [Keys.shift],
- // hash: hashShift
- // });
- };
- }, []);
+ if (activeTool === 'crosshair') {
+ return;
+ }
+
+ const drawingTool = activeTool;
+
+ if (trendLines().some(({ value }) => value === drawingTool)) {
+ setSelectedLineType(drawingTool);
+ return;
+ }
+ if (gannAndFibonacciTools().some(({ value }) => value === drawingTool)) {
+ setSelectedGannAndFibonacci(drawingTool);
+ return;
+ }
+ if (geometricShapes().some(({ value }) => value === drawingTool)) {
+ setSelectedGeometricShape(drawingTool);
+ return;
+ }
+ if (measurementTools().some(({ value }) => value === drawingTool)) {
+ setSelectedMeasurementTool(drawingTool);
+ }
+ }, [activeTool]);
return (
<div
@@ -179,6 +142,7 @@ export default function Toolbar({
/>
</Tooltip>
)}
+
{implemented.lines && (
<SplitDropdown
anchorRef={toolbarRef}
@@ -197,6 +161,7 @@ export default function Toolbar({
/>
</SplitDropdown>
)}
+
{implemented.fib && (
<SplitDropdown
anchorRef={toolbarRef}
@@ -215,6 +180,7 @@ export default function Toolbar({
/>
</SplitDropdown>
)}
+
{implemented.rectangle && (
<SplitDropdown
anchorRef={toolbarRef}
@@ -233,6 +199,7 @@ export default function Toolbar({
/>
</SplitDropdown>
)}
+
{implemented.text && (
<Tooltip
tooltipClassName={getTooltipClassName()}
@@ -248,6 +215,7 @@ export default function Toolbar({
/>
</Tooltip>
)}
+
{implemented.XABCD && (
<Tooltip
tooltipClassName={getTooltipClassName()}
@@ -263,6 +231,7 @@ export default function Toolbar({
/>
</Tooltip>
)}
+
{implemented.position && (
<SplitDropdown
anchorRef={toolbarRef}
@@ -281,6 +250,7 @@ export default function Toolbar({
/>
</SplitDropdown>
)}
+
{implemented.icons && (
<Tooltip
label={t('Pin')}
@@ -297,10 +267,12 @@ export default function Toolbar({
</Tooltip>
)}
</div>
+
<Divider
direction="horizontal"
pt={{ divider: { className: styles.divider } }}
/>
+
<div className={classNames(styles.group)}>
<Tooltip
tooltipClassName={getTooltipClassName()}
@@ -331,10 +303,12 @@ export default function Toolbar({
/>
</Tooltip>
</div>
+
<Divider
direction="horizontal"
pt={{ divider: { className: classNames(styles.divider) } }}
/>
+
<div className={classNames(styles.group)}>
<Tooltip
tooltipClassName={getTooltipClassName()}
@@ -395,10 +369,12 @@ export default function Toolbar({
/>
</Tooltip>
</div>
+
<Divider
direction="horizontal"
pt={{ divider: { className: classNames(styles.divider) } }}
/>
+
<div className={classNames(styles.group)}>
<Tooltip
tooltipClassName={getTooltipClassName()}
diff --git a/src/core/Drawings.ts b/src/core/Drawings.ts
index 58e6e16..95f7c67 100644
--- a/src/core/Drawings.ts
+++ b/src/core/Drawings.ts
@@ -23,7 +23,6 @@ interface DrawingParams extends DOMObjectParams {
deselect: () => void;
isLocked?: boolean;
hotkeys: Hotkeys;
- resetActiveTool: () => void;
}
export class Drawing extends DOMObject {
@@ -35,7 +34,6 @@ export class Drawing extends DOMObject {
private settingsSubject: BehaviorSubject<SettingsValues>;
private subscriptions = new Subscription();
- private escapeUnregisterHash: string | null = null;
private deleteUnregisterHash: string | null = null;
private copyUnregisterHash: string | null = null;
@@ -58,7 +56,6 @@ export class Drawing extends DOMObject {
isLocked = false,
paneId,
hotkeys,
- resetActiveTool,
}: DrawingParams) {
super({
id,
@@ -93,14 +90,6 @@ export class Drawing extends DOMObject {
}),
);
- this.escapeUnregisterHash = hotkeys.register({
- keys: [Keys.escape],
- callback: () => {
- this.delete();
- resetActiveTool();
- },
- });
-
this.subscriptions.add(
selected$.subscribe((isSelectedDrawing) => {
if (isSelectedDrawing) {
@@ -126,15 +115,6 @@ export class Drawing extends DOMObject {
this.unregisterSelectedDrawingHotkeys();
}),
);
-
- this.waitForCreation().then(() => {
- hotkeys.unregister({
- keys: [Keys.escape],
- hash: this.escapeUnregisterHash,
- });
-
- this.escapeUnregisterHash = null;
- });
}
public getDrawingName(): DrawingsNames {
@@ -231,13 +211,6 @@ export class Drawing extends DOMObject {
this.subscriptions.unsubscribe();
this.unregisterSelectedDrawingHotkeys();
- this.hotkeys.unregister({
- keys: [Keys.escape],
- hash: this.escapeUnregisterHash,
- });
-
- this.escapeUnregisterHash = null;
-
this.lockedSubject.complete();
this.settingsSubject.complete();
diff --git a/src/core/DrawingsManager.tsx b/src/core/DrawingsManager.tsx
index ac05055..0166842 100644
--- a/src/core/DrawingsManager.tsx
+++ b/src/core/DrawingsManager.tsx
@@ -31,6 +31,7 @@ interface DrawingsManagerParams {
setActiveTool: (name: ActiveDrawingTool) => void;
getActiveTool: () => ActiveDrawingTool;
getIsEndlessMode: () => boolean;
+ continueDrawing: (name: DrawingsNames) => void;
}
export interface DrawingSnapshotItem extends Partial<DOMObjectSnapshot> {
@@ -66,13 +67,13 @@ export class DrawingsManager {
private selectedDrawing$ = new BehaviorSubject<Drawing | null>(null); // todo: переместить в DrawingsManagerCollection
private pendingSnapshot: DrawingsManagerSnapshot | null = null;
private selectedDrawingSnapshot: DrawingSnapshotItem | null = null;
- private recreateScheduled = false;
private pane: Pane;
private copyPasteBuffer: DrawingSnapshotItem | null = null;
private setActiveTool: (name: ActiveDrawingTool) => void;
private getActiveTool: () => ActiveDrawingTool;
private getIsEndlessMode: () => boolean;
+ private continueDrawing: (name: DrawingsNames) => void;
constructor({
eventManager,
@@ -87,6 +88,7 @@ export class DrawingsManager {
setActiveTool,
getActiveTool,
getIsEndlessMode,
+ continueDrawing,
}: DrawingsManagerParams) {
this.DOM = DOM;
this.eventManager = eventManager;
@@ -99,6 +101,7 @@ export class DrawingsManager {
this.setActiveTool = setActiveTool;
this.getActiveTool = getActiveTool;
this.getIsEndlessMode = getIsEndlessMode;
+ this.continueDrawing = continueDrawing;
this.subscriptions.add(
mainSeries$.subscribe((series) => {
@@ -196,7 +199,6 @@ export class DrawingsManager {
});
this.DOM.refreshEntities();
- this.updateActiveTool();
};
private handleDoubleClick = (event: MouseEvent): void => {
@@ -218,7 +220,6 @@ export class DrawingsManager {
drawing.getSeriesDrawing().doubleClick(event);
this.DOM.refreshEntities();
- this.updateActiveTool();
};
private handleContextMenu = (event: MouseEvent): void => {
@@ -361,7 +362,7 @@ export class DrawingsManager {
});
}
- private updateActiveTool = (): void => {
+ private updateActiveTool(): void {
const hasPendingDrawing = this.drawings$.value.some((drawing) => drawing.isCreationPending());
if (hasPendingDrawing) {
@@ -369,45 +370,15 @@ export class DrawingsManager {
}
const activeTool = this.getActiveTool();
- const isSingleInstanceTool = activeTool !== 'crosshair' && drawingsMap[activeTool]?.singleInstance;
- if (activeTool !== 'crosshair' && this.getIsEndlessMode() && !isSingleInstanceTool) {
- if (this.recreateScheduled) {
- return;
- }
-
- this.recreateScheduled = true;
-
- queueMicrotask(() => {
- this.recreateScheduled = false;
-
- const currentTool = this.getActiveTool();
- const hasPendingAfterTick = this.drawings$.value.some((drawing) => drawing.isCreationPending());
-
- if (currentTool === 'crosshair') {
- return;
- }
-
- if (!this.getIsEndlessMode()) {
- return;
- }
-
- if (drawingsMap[currentTool]?.singleInstance) {
- return;
- }
-
- if (hasPendingAfterTick) {
- return;
- }
-
- this.addDrawingForce(currentTool);
- });
+ if (activeTool !== 'crosshair' && this.getIsEndlessMode()) {
+ this.continueDrawing(activeTool);
return;
}
this.setActiveTool('crosshair');
- };
+ }
private removeDrawing = (id: string): void => {
const drawing = this.findDrawing(id);
@@ -469,7 +440,11 @@ export class DrawingsManager {
this.DOM.refreshEntities();
}
- public addDrawingForce = async (name: DrawingsNames, event?: MouseEventParams): Promise<void> => {
+ public addDrawingForce = async (
+ name: DrawingsNames,
+ event?: MouseEventParams,
+ shouldContinueDrawing = true,
+ ): Promise<void> => {
this.removePendingDrawings(false);
const previousDrawing = drawingsMap[name].singleInstance
@@ -482,8 +457,17 @@ export class DrawingsManager {
this.removeDrawingInternal(previousDrawing.id, false);
}
+ if (this.selectedDrawing$.value) {
+ this.selectedDrawing$.next(null);
+ }
+
this.setActiveTool(name);
- const drawing = this.createDrawing({ name, event });
+
+ const drawing = this.createDrawing({
+ name,
+ event,
+ });
+
this.DOM.refreshEntities();
await drawing.waitForCreation();
@@ -496,7 +480,18 @@ export class DrawingsManager {
return;
}
+ this.selectedDrawing$.next(drawing);
this.pushDrawingChange(previousSnapshot, this.createDrawingSnapshot(drawing));
+
+ if (this.getActiveTool() === name) {
+ if (shouldContinueDrawing) {
+ this.updateActiveTool();
+ } else {
+ this.setActiveTool('crosshair');
+ }
+ }
+
+ this.DOM.refreshEntities();
};
private createDrawing({
@@ -515,11 +510,6 @@ export class DrawingsManager {
}
const { id, state, isLocked = false, zIndex, shouldUpdateDrawingsList = true } = options;
- const shouldSelectAfterCreation = state === undefined;
-
- if (shouldSelectAfterCreation && this.selectedDrawing$.value) {
- this.selectedDrawing$.next(null);
- }
const config = drawingsMap[name];
const drawingId = id ?? crypto.randomUUID();
@@ -593,9 +583,6 @@ export class DrawingsManager {
isLocked,
paneId: this.paneId,
hotkeys: this.hotkeys,
- resetActiveTool: () => {
- this.setActiveTool('crosshair');
- },
});
const entity = this.DOM.setEntity<Drawing>(drawingFactory, zIndex);
@@ -610,18 +597,6 @@ export class DrawingsManager {
this.drawings$.next([...this.drawings$.value, entity].sort((left, right) => left.zIndex - right.zIndex));
}
- if (shouldSelectAfterCreation) {
- entity.waitForCreation().then(() => {
- if (!this.drawings$.value.includes(entity)) {
- return;
- }
-
- this.selectedDrawing$.next(entity);
- this.updateActiveTool();
- this.DOM.refreshEntities();
- });
- }
-
return entity;
}
@@ -674,7 +649,6 @@ export class DrawingsManager {
public activateCrosshair(): void {
this.removePendingDrawings(false);
- this.setActiveTool('crosshair');
this.DOM.refreshEntities();
}
diff --git a/src/core/DrawingsManagerCollection.ts b/src/core/DrawingsManagerCollection.ts
index f5a4573..dd0cd52 100644
--- a/src/core/DrawingsManagerCollection.ts
+++ b/src/core/DrawingsManagerCollection.ts
@@ -6,7 +6,16 @@ import { ActiveDrawingTool, SettingsValues } from '@src/types';
import { Drawing } from './Drawings';
import { DrawingsManager } from './DrawingsManager';
import { Hotkeys, Keys } from './Hotkeys';
-import { PaneManager } from './PaneManager';
+
+import type { MouseEventParams } from 'lightweight-charts';
+import type { Pane } from './Pane';
+import type { PaneManager } from './PaneManager';
+
+interface HotkeyRegistration {
+ keys: Keys[];
+ hash: string | null;
+}
+
// todo: нужно дописывать класс)
export class DrawingsManagerCollection {
private managersMap: Map<number, DrawingsManager> = new Map();
@@ -16,11 +25,54 @@ export class DrawingsManagerCollection {
private activeTool$ = new BehaviorSubject<ActiveDrawingTool>('crosshair');
private endlessMode$ = new BehaviorSubject(false);
private paneClickListenerUnsub = () => {};
- private escapeUnregisterHash: string | null = null;
+ private hotkeyRegistrations: HotkeyRegistration[] = [];
constructor({ paneCollection, hotkeys }: { paneCollection: PaneManager; hotkeys: Hotkeys }) {
this.paneCollection = paneCollection;
this.hotkeys = hotkeys;
+
+ const drawingShortcuts: { keys: Keys[]; drawingName: DrawingsNames }[] = [
+ {
+ keys: [Keys.alt, Keys.t],
+ drawingName: DrawingsNames.trendLine,
+ },
+ {
+ keys: [Keys.alt, Keys.h],
+ drawingName: DrawingsNames.horizontalLine,
+ },
+ {
+ keys: [Keys.alt, Keys.v],
+ drawingName: DrawingsNames.verticalLine,
+ },
+ {
+ keys: [Keys.alt, Keys.f],
+ drawingName: DrawingsNames.fibonacciRetracement,
+ },
+ {
+ keys: [Keys.alt, Keys.shift, Keys.r],
+ drawingName: DrawingsNames.rectangle,
+ },
+ ];
+
+ this.hotkeyRegistrations = drawingShortcuts.map(({ keys, drawingName }) => ({
+ keys,
+ hash: this.hotkeys.register({
+ keys,
+ callback: () => {
+ this.addDrawingForce(drawingName);
+ },
+ }),
+ }));
+
+ const escapeKeys = [Keys.escape];
+
+ this.hotkeyRegistrations.push({
+ keys: escapeKeys,
+ hash: this.hotkeys.register({
+ keys: escapeKeys,
+ callback: this.activateCrosshair,
+ }),
+ });
}
public getIsEndlessMode(): boolean {
@@ -31,40 +83,39 @@ export class DrawingsManagerCollection {
return this.activeTool$.value;
}
- public setActiveTool(next: ActiveDrawingTool) {
+ public setActiveTool(next: ActiveDrawingTool): void {
this.activeTool$.next(next);
}
- public removeDrawingManager(paneId: number) {
+ public removeDrawingManager(paneId: number): void {
this.managersMap.delete(paneId);
}
- public addDrawingManager(manager: DrawingsManager, paneId: number) {
+ public addDrawingManager(manager: DrawingsManager, paneId: number): void {
this.managersMap.set(paneId, manager);
}
- public addDrawingForce = async (name: DrawingsNames): Promise<void> => {
+ public addDrawingForce = (name: DrawingsNames): void => {
this.paneClickListenerUnsub();
this.setActiveTool(name);
this.paneClickListenerUnsub = this.paneCollection.listenPanesToAddDrawing(name);
};
- public setEndlessDrawingMode = (value: boolean): void => {
- if (value) {
- this.escapeUnregisterHash = this.hotkeys.register({
- keys: [Keys.escape],
- callback: () => {
- this.setEndlessDrawingMode(false);
- },
- });
- } else {
- this.hotkeys.unregister({
- keys: [Keys.escape],
- hash: this.escapeUnregisterHash,
- });
+ public handlePaneClick(pane: Pane, event: MouseEventParams): void {
+ const isQuickMeasure = this.activeTool$.value === 'crosshair' && event.sourceEvent?.shiftKey === true;
+
+ if (isQuickMeasure) {
+ pane.getDrawingManager().addDrawingForce(DrawingsNames.ruler, event, false);
+ return;
+ }
- this.escapeUnregisterHash = null;
+ pane.fireClick(event);
+ }
+
+ public setEndlessDrawingMode = (value: boolean): void => {
+ if (this.endlessMode$.value === value) {
+ return;
}
this.endlessMode$.next(value);
@@ -74,13 +125,14 @@ export class DrawingsManagerCollection {
return this.endlessMode$.asObservable();
}
- public activateCrosshair(): void {
+ public activateCrosshair = (): void => {
this.paneClickListenerUnsub();
+ this.setActiveTool('crosshair');
Array.from(this.managersMap.values()).forEach((manager) => {
manager.activateCrosshair();
});
- }
+ };
public getActiveTool(): Observable<ActiveDrawingTool> {
return this.activeTool$.asObservable();
@@ -108,13 +160,17 @@ export class DrawingsManagerCollection {
Array.from(this.managersMap.values())[0].deleteSelectedDrawing();
};
- public destroy() {
- this.hotkeys.unregister({
- keys: [Keys.escape],
- hash: this.escapeUnregisterHash,
+ public destroy(): void {
+ this.hotkeyRegistrations.forEach(({ keys, hash }) => {
+ this.hotkeys.unregister({
+ keys,
+ hash,
+ });
});
- this.activeTool$.complete();
+ this.hotkeyRegistrations = [];
this.paneClickListenerUnsub();
+ this.activeTool$.complete();
+ this.endlessMode$.complete();
}
}
diff --git a/src/core/Hotkeys.ts b/src/core/Hotkeys.ts
index cfa9019..8f9c38c 100644
--- a/src/core/Hotkeys.ts
+++ b/src/core/Hotkeys.ts
@@ -11,6 +11,8 @@ export enum Keys {
'h' = 'keyh',
'v' = 'keyv',
'f' = 'keyf',
+ 'r' = 'keyr',
+ 'y' = 'keyy',
'z' = 'keyz',
'c' = 'keyc',
'mousedown' = 'mousedown',
diff --git a/src/core/MoexChart.tsx b/src/core/MoexChart.tsx
index 622fad5..f020aa6 100644
--- a/src/core/MoexChart.tsx
+++ b/src/core/MoexChart.tsx
@@ -189,6 +189,11 @@ export class MoexChart implements ISerializable<MoexChartSnapshot> {
callback: undoRedo.undo,
});
+ this.hotkeys.register({
+ keys: [Keys.mod, Keys.y],
+ callback: undoRedo.redo,
+ });
+
this.hotkeys.register({
keys: [Keys.mod, Keys.shift, Keys.z],
callback: undoRedo.redo,
@@ -367,7 +372,6 @@ export class MoexChart implements ISerializable<MoexChartSnapshot> {
isEndlessDrawingsMode$={drawingCollection.isEndlessDrawingsMode()}
activateCrosshair={() => drawingCollection.activateCrosshair()}
activeTool$={drawingCollection.getActiveTool()}
- hotkeys={this.hotkeys}
/>,
);
}
diff --git a/src/core/Pane.tsx b/src/core/Pane.tsx
index 753f7bf..1cba496 100644
--- a/src/core/Pane.tsx
+++ b/src/core/Pane.tsx
@@ -58,6 +58,7 @@ export interface PaneParams {
setActiveTool: (name: ActiveDrawingTool) => void;
getActiveTool: () => ActiveDrawingTool;
getIsEndlessMode: () => boolean;
+ continueDrawing: (name: DrawingsNames) => void;
}
// todo: Pane, ему должна принадлежать mainSerie, а также IndicatorManager и drawingsManager, mouseEvents. Также перекинуть соответствующие/необходимые свойства из чарта, и из чарта удалить
@@ -65,7 +66,6 @@ export interface PaneParams {
// todo: в CompareManage, при создании нового пейна для сравнения - инициализируем новый dataSource, принадлежащий только конкретному пейну. Убираем возможность добавлять индикаторы на такие пейны
// todo: на каждый символ свой DataSource (учитывать что есть MainPane и "главный" DataSource, который инициализиурется во время старта moexChart)
// todo: сделать два разных представления для compare, в зависимости от отображения на главном пейне или на второстепенном
-
export class Pane implements ISerializable<PaneSnapshot> {
private readonly id: number;
private readonly isMain: boolean;
@@ -122,6 +122,7 @@ export class Pane implements ISerializable<PaneSnapshot> {
setActiveTool,
getActiveTool,
getIsEndlessMode,
+ continueDrawing,
}: PaneParams) {
this.onDelete = onDelete;
this.onPriceScaleStateChange = onPriceScaleStateChange;
@@ -194,6 +195,7 @@ export class Pane implements ISerializable<PaneSnapshot> {
setActiveTool,
getActiveTool,
getIsEndlessMode,
+ continueDrawing,
});
addDrawingManager(this.drawingsManager, this.id);
@@ -344,6 +346,7 @@ export class Pane implements ISerializable<PaneSnapshot> {
cancelAnimationFrame(this.paneContainerSyncFrameId);
this.paneContainerSyncFrameId = null;
}
+
this.drawingsManager.destroy();
this.subscriptions.unsubscribe();
diff --git a/src/core/PaneManager.ts b/src/core/PaneManager.ts
index 20f8034..348f708 100644
--- a/src/core/PaneManager.ts
+++ b/src/core/PaneManager.ts
@@ -28,7 +28,8 @@ type CollectionDependencies =
| 'removeDrawingManager'
| 'setActiveTool'
| 'getActiveTool'
- | 'getIsEndlessMode';
+ | 'getIsEndlessMode'
+ | 'continueDrawing';
interface PaneManagerStartParams {
compareEntities$: Observable<Indicator[]>;
@@ -42,7 +43,6 @@ type SharedPaneParams = Omit<PaneManagerParams, 'panesSnapshot'>;
// todo: в CompareManage, при создании нового пейна для сравнения - инициализируем новый dataSource, принадлежащий только конкретному пейну. Убираем возможность добавлять индикаторы на такие пейны
// todo: на каждый символ свой DataSource (учитывать что есть MainPane и "главный" DataSource, который инициализиурется во время старта moexChart)
// todo: сделать два разных представления для compare, в зависимости от отображения на главном пейне или на второстепенном
-
export class PaneManager implements ISerializable<PaneSnapshot[]> {
private readonly sharedPaneParams: SharedPaneParams;
private readonly lwcChart: IChartApi;
@@ -119,6 +119,7 @@ export class PaneManager implements ISerializable<PaneSnapshot[]> {
public listenPanesToAddDrawing(name: DrawingsNames): () => void {
const panes = Array.from(this.panesMap.values());
+
const unsub = () => {
panes.forEach((pane) => {
pane.unsubscribeInitialDrawingClick();
@@ -236,9 +237,17 @@ export class PaneManager implements ISerializable<PaneSnapshot[]> {
private initClickListener(): void {
const handler = (param: MouseEventParams) => {
- if (param.paneIndex === undefined) return;
+ if (param.paneIndex === undefined) {
+ return;
+ }
+
const clickedPane = this.getPaneByIndex(param.paneIndex);
- clickedPane?.fireClick(param);
+
+ if (!clickedPane) {
+ return;
+ }
+
+ this.drawingsManagerCollection.handlePaneClick(clickedPane, param);
};
this.lwcChart.subscribeClick(handler);
@@ -260,8 +269,6 @@ export class PaneManager implements ISerializable<PaneSnapshot[]> {
const paneIndex = pane.paneIndex();
- this.subscriptions.unsubscribe();
-
this.panesMap.delete(id);
pane.destroy();
@@ -289,6 +296,7 @@ export class PaneManager implements ISerializable<PaneSnapshot[]> {
setActiveTool: (name: ActiveDrawingTool) => this.drawingsManagerCollection.setActiveTool(name),
getActiveTool: () => this.drawingsManagerCollection.getActiveToolValue(),
getIsEndlessMode: () => this.drawingsManagerCollection.getIsEndlessMode(),
+ continueDrawing: (name: DrawingsNames) => this.drawingsManagerCollection.addDrawingForce(name),
};
}