lightweight-charts-drawing 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +7 -0
- package/dist/index.d.ts +19 -3
- package/dist/lightweight-charts-drawing.es.js +32 -6
- package/dist/lightweight-charts-drawing.es.js.map +1 -1
- package/dist/lightweight-charts-drawing.umd.cjs +7 -7
- package/dist/lightweight-charts-drawing.umd.cjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0 (08/10/2026)
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `DrawingManager.setHidden(id, hidden)`: hide / show one drawing without
|
|
8
|
+
removing it (the drawing's `hidden` flag, saved with it).
|
|
9
|
+
- `DrawingManager.setDrawingsVisible(visible)` / `drawingsVisible()` and the
|
|
10
|
+
`visibility` event: hide / show every drawing at once (TradingView "Hide
|
|
11
|
+
all drawings"). Not saved, the drawings are untouched. Hiding disarms the
|
|
12
|
+
tool; arming a tool shows the drawings again.
|
|
13
|
+
- Demo: hide all button, hide button in the selection bar.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- A drawing that stops being shown (`hidden`, per-interval visibility) leaves
|
|
18
|
+
the selection and the hover: Delete could remove a drawing that was not
|
|
19
|
+
drawn.
|
|
20
|
+
|
|
3
21
|
## 0.4.0 (02/10/2026)
|
|
4
22
|
|
|
5
23
|
### Added
|
package/README.md
CHANGED
|
@@ -61,6 +61,8 @@ intraday of date labels), `stayInDrawingMode` (TV Keep drawing).
|
|
|
61
61
|
| `setTool(kind \| null, { glyph? })`, `tool()` | arm / disarm a tool (`kind` from docs/TOOLS.md) |
|
|
62
62
|
| `setMagnet(mode)`, `setInterval(i)`, `setStayInDrawingMode(on)` | settings |
|
|
63
63
|
| `add(drawing)`, `update(drawing)`, `remove(id)`, `clear()`, `get(id)`, `drawings()` | drawings |
|
|
64
|
+
| `setHidden(id, hidden)` | hide / show one drawing without removing it (the drawing's `hidden` flag, saved with it) |
|
|
65
|
+
| `setDrawingsVisible(visible)`, `drawingsVisible()` | hide / show every drawing at once (TV "Hide all drawings"; not saved, the drawings are untouched) |
|
|
64
66
|
| `select(ids)`, `selection()` | selection (multi-select with Ctrl / Cmd) |
|
|
65
67
|
| `bringToFront(id)`, `sendToBack(id)` | z-order |
|
|
66
68
|
| `toggleAnchored(id)` | TV "Anchor drawing" for Text, Pin and Table: the drawing keeps its pane position when the chart scrolls (`isAnchorable(kind)`) |
|
|
@@ -71,6 +73,7 @@ intraday of date labels), `stayInDrawingMode` (TV Keep drawing).
|
|
|
71
73
|
| `redraw()`, `destroy()` | |
|
|
72
74
|
|
|
73
75
|
Events: `change`, `add`, `update`, `remove`, `selection`, `tool`,
|
|
76
|
+
`visibility` (every drawing hidden / shown again),
|
|
74
77
|
`textEdit` (a text tool was placed or double-clicked: open your editor at
|
|
75
78
|
the given pane point and `update` the drawing's `text`), `tableEdit` (a click
|
|
76
79
|
on a cell of the selected table: open your editor over the given cell box),
|
|
@@ -84,6 +87,10 @@ steps / square boxes and magnet off, Ctrl / Cmd inverts the magnet; Escape
|
|
|
84
87
|
drops pending points, then the tool, then the selection; Delete removes the
|
|
85
88
|
selection (locked drawings stay).
|
|
86
89
|
|
|
90
|
+
Drawing flags: `locked` (selectable, but no drag and no Delete) and `hidden`
|
|
91
|
+
(not drawn, hit or selected). A drawing that gets hidden leaves the
|
|
92
|
+
selection. Arming a tool while every drawing is hidden shows them again.
|
|
93
|
+
|
|
87
94
|
The host keeps what is not drawing logic: undo stack, storage, settings
|
|
88
95
|
dialogs, text / table editors, toolbar, context menu.
|
|
89
96
|
|
package/dist/index.d.ts
CHANGED
|
@@ -183,6 +183,8 @@ export declare class DrawingManager {
|
|
|
183
183
|
private readonly listeners;
|
|
184
184
|
private list;
|
|
185
185
|
private selected;
|
|
186
|
+
/** TV "Hide all drawings": off = nothing is drawn or hit (not saved). */
|
|
187
|
+
private visible;
|
|
186
188
|
private hovered;
|
|
187
189
|
private spec;
|
|
188
190
|
private glyph;
|
|
@@ -206,6 +208,7 @@ export declare class DrawingManager {
|
|
|
206
208
|
on(event: "remove", cb: DrawingManagerEvents["remove"]): () => void;
|
|
207
209
|
on(event: "selection", cb: DrawingManagerEvents["selection"]): () => void;
|
|
208
210
|
on(event: "tool", cb: DrawingManagerEvents["tool"]): () => void;
|
|
211
|
+
on(event: "visibility", cb: DrawingManagerEvents["visibility"]): () => void;
|
|
209
212
|
on(event: "textEdit", cb: DrawingManagerEvents["textEdit"]): () => void;
|
|
210
213
|
on(event: "gestureEnd", cb: DrawingManagerEvents["gestureEnd"]): () => void;
|
|
211
214
|
on(event: "tableEdit", cb: DrawingManagerEvents["tableEdit"]): () => void;
|
|
@@ -217,12 +220,20 @@ export declare class DrawingManager {
|
|
|
217
220
|
tool(): DrawingKind | null;
|
|
218
221
|
setMagnet(mode: MagnetMode): void;
|
|
219
222
|
setInterval(interval: string | undefined): void;
|
|
223
|
+
/** TV "Hide all drawings": hide / show every drawing without touching
|
|
224
|
+
* them (the drawings' own `hidden` flag and the saved JSON stay as they
|
|
225
|
+
* are). Hiding disarms the tool and clears the selection. */
|
|
226
|
+
setDrawingsVisible(visible: boolean): void;
|
|
227
|
+
drawingsVisible(): boolean;
|
|
220
228
|
setStayInDrawingMode(on: boolean): void;
|
|
221
229
|
drawings(): readonly Drawing[];
|
|
222
230
|
get(id: string): Drawing | undefined;
|
|
223
231
|
/** Add a drawing (default style of its kind when none); returns its id. */
|
|
224
232
|
add(nd: NewDrawing | Drawing): string;
|
|
225
233
|
update(d: Drawing): void;
|
|
234
|
+
/** Hide / show one drawing (its `hidden` flag, saved with it): a hidden
|
|
235
|
+
* drawing is not drawn, hit or selected. */
|
|
236
|
+
setHidden(id: string, hidden: boolean): void;
|
|
226
237
|
remove(id: string): void;
|
|
227
238
|
clear(): void;
|
|
228
239
|
/** Z-order (TV Visual order): the list order is the draw order. */
|
|
@@ -287,6 +298,9 @@ export declare class DrawingManager {
|
|
|
287
298
|
private changed;
|
|
288
299
|
private reorder;
|
|
289
300
|
private shown;
|
|
301
|
+
/** Drawings that are no longer shown leave the selection and the hover:
|
|
302
|
+
* Delete must not remove a drawing the user cannot see. */
|
|
303
|
+
private dropHidden;
|
|
290
304
|
private paneSize;
|
|
291
305
|
/** Pointer position in pane coordinates. */
|
|
292
306
|
private panePoint;
|
|
@@ -334,6 +348,9 @@ export declare type DrawingManagerEvents = {
|
|
|
334
348
|
selection: (ids: readonly string[]) => void;
|
|
335
349
|
/** The armed tool changed (null = none). */
|
|
336
350
|
tool: (kind: DrawingKind | null) => void;
|
|
351
|
+
/** Every drawing was hidden or shown again (setDrawingsVisible, or a tool
|
|
352
|
+
* armed while they were hidden). */
|
|
353
|
+
visibility: (visible: boolean) => void;
|
|
337
354
|
/** A text tool was placed (or double-clicked): the host opens its editor
|
|
338
355
|
* at `screen` (pane coordinates) and calls update with the text. */
|
|
339
356
|
textEdit: (d: Drawing, screen: Pt) => void;
|
|
@@ -1474,9 +1491,8 @@ declare type WithId<T> = T & {
|
|
|
1474
1491
|
closed?: boolean;
|
|
1475
1492
|
/** Locked drawings can be selected but not dragged or deleted via Delete-key. */
|
|
1476
1493
|
locked?: boolean;
|
|
1477
|
-
/** Hidden drawings are not rendered
|
|
1478
|
-
*
|
|
1479
|
-
* (not yet built). */
|
|
1494
|
+
/** Hidden drawings are not rendered, hit-tested or selected; the flag is
|
|
1495
|
+
* saved with the drawing (DrawingManager.setHidden). */
|
|
1480
1496
|
hidden?: boolean;
|
|
1481
1497
|
/** Per-interval visibility matrix (Settings → Visibility). Absent = always
|
|
1482
1498
|
* visible (the default for drawings saved before this field existed). */
|
|
@@ -5878,9 +5878,11 @@ class Ja {
|
|
|
5878
5878
|
H(this, "coords");
|
|
5879
5879
|
H(this, "primitive");
|
|
5880
5880
|
H(this, "el");
|
|
5881
|
-
H(this, "listeners", { change: /* @__PURE__ */ new Set(), add: /* @__PURE__ */ new Set(), update: /* @__PURE__ */ new Set(), remove: /* @__PURE__ */ new Set(), selection: /* @__PURE__ */ new Set(), tool: /* @__PURE__ */ new Set(), textEdit: /* @__PURE__ */ new Set(), gestureEnd: /* @__PURE__ */ new Set(), tableEdit: /* @__PURE__ */ new Set() });
|
|
5881
|
+
H(this, "listeners", { change: /* @__PURE__ */ new Set(), add: /* @__PURE__ */ new Set(), update: /* @__PURE__ */ new Set(), remove: /* @__PURE__ */ new Set(), selection: /* @__PURE__ */ new Set(), tool: /* @__PURE__ */ new Set(), visibility: /* @__PURE__ */ new Set(), textEdit: /* @__PURE__ */ new Set(), gestureEnd: /* @__PURE__ */ new Set(), tableEdit: /* @__PURE__ */ new Set() });
|
|
5882
5882
|
H(this, "list", []);
|
|
5883
5883
|
H(this, "selected", []);
|
|
5884
|
+
/** TV "Hide all drawings": off = nothing is drawn or hit (not saved). */
|
|
5885
|
+
H(this, "visible", !0);
|
|
5884
5886
|
H(this, "hovered", null);
|
|
5885
5887
|
H(this, "spec", null);
|
|
5886
5888
|
H(this, "glyph");
|
|
@@ -5916,7 +5918,7 @@ class Ja {
|
|
|
5916
5918
|
* the font-icon glyph to place. */
|
|
5917
5919
|
setTool(t, n = {}) {
|
|
5918
5920
|
const o = t ? sn(t) ?? null : null;
|
|
5919
|
-
this.spec = o, this.glyph = n.glyph, this.pending = [], this.cursor = null, this.emit("tool", o ? o.kind : null), this.redraw();
|
|
5921
|
+
o && this.setDrawingsVisible(!0), this.spec = o, this.glyph = n.glyph, this.pending = [], this.cursor = null, this.emit("tool", o ? o.kind : null), this.redraw();
|
|
5920
5922
|
}
|
|
5921
5923
|
tool() {
|
|
5922
5924
|
var t;
|
|
@@ -5926,7 +5928,16 @@ class Ja {
|
|
|
5926
5928
|
this.opts.magnet = t;
|
|
5927
5929
|
}
|
|
5928
5930
|
setInterval(t) {
|
|
5929
|
-
this.opts.interval = t, this.redraw();
|
|
5931
|
+
this.opts.interval = t, this.dropHidden(), this.redraw();
|
|
5932
|
+
}
|
|
5933
|
+
/** TV "Hide all drawings": hide / show every drawing without touching
|
|
5934
|
+
* them (the drawings' own `hidden` flag and the saved JSON stay as they
|
|
5935
|
+
* are). Hiding disarms the tool and clears the selection. */
|
|
5936
|
+
setDrawingsVisible(t) {
|
|
5937
|
+
this.visible !== t && (this.visible = t, t || (this.spec && this.setTool(null), this.dropHidden()), this.emit("visibility", t), this.redraw());
|
|
5938
|
+
}
|
|
5939
|
+
drawingsVisible() {
|
|
5940
|
+
return this.visible;
|
|
5930
5941
|
}
|
|
5931
5942
|
setStayInDrawingMode(t) {
|
|
5932
5943
|
this.opts.stayInDrawingMode = t;
|
|
@@ -5944,7 +5955,13 @@ class Ja {
|
|
|
5944
5955
|
}
|
|
5945
5956
|
update(t) {
|
|
5946
5957
|
const n = this.get(t.id);
|
|
5947
|
-
n && (this.list = this.list.map((o) => o.id === t.id ? t : o), this.emit("update", t, n), this.changed());
|
|
5958
|
+
n && (this.list = this.list.map((o) => o.id === t.id ? t : o), this.dropHidden(), this.emit("update", t, n), this.changed());
|
|
5959
|
+
}
|
|
5960
|
+
/** Hide / show one drawing (its `hidden` flag, saved with it): a hidden
|
|
5961
|
+
* drawing is not drawn, hit or selected. */
|
|
5962
|
+
setHidden(t, n) {
|
|
5963
|
+
const o = this.get(t);
|
|
5964
|
+
!o || !!o.hidden === n || this.update({ ...o, hidden: n });
|
|
5948
5965
|
}
|
|
5949
5966
|
remove(t) {
|
|
5950
5967
|
const n = this.get(t);
|
|
@@ -6111,7 +6128,16 @@ class Ja {
|
|
|
6111
6128
|
i.splice(Math.max(0, Math.min(i.length, n)), 0, r), this.list = i, this.changed();
|
|
6112
6129
|
}
|
|
6113
6130
|
shown(t) {
|
|
6114
|
-
return !t.hidden && (this.opts.interval == null || pr(t.visibility, this.opts.interval));
|
|
6131
|
+
return this.visible && !t.hidden && (this.opts.interval == null || pr(t.visibility, this.opts.interval));
|
|
6132
|
+
}
|
|
6133
|
+
/** Drawings that are no longer shown leave the selection and the hover:
|
|
6134
|
+
* Delete must not remove a drawing the user cannot see. */
|
|
6135
|
+
dropHidden() {
|
|
6136
|
+
const t = (n) => {
|
|
6137
|
+
const o = this.get(n);
|
|
6138
|
+
return !!o && this.shown(o);
|
|
6139
|
+
};
|
|
6140
|
+
this.hovered && !t(this.hovered.id) && (this.hovered = null, this.hoverCursor = null), this.selected.every(t) || this.select(this.selected.filter(t));
|
|
6115
6141
|
}
|
|
6116
6142
|
paneSize() {
|
|
6117
6143
|
const t = this.series.getPane().paneIndex(), n = this.chart.paneSize(t);
|
|
@@ -6460,7 +6486,7 @@ class Na {
|
|
|
6460
6486
|
});
|
|
6461
6487
|
}
|
|
6462
6488
|
}
|
|
6463
|
-
const tf = "0.
|
|
6489
|
+
const tf = "0.5.0";
|
|
6464
6490
|
export {
|
|
6465
6491
|
La as ANCHORABLE_KINDS,
|
|
6466
6492
|
Mn as DEFAULT_STYLE,
|