@baron1996/klinecharts-runtime 0.3.0 → 0.4.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/README.md +1 -1
- package/dist/drawing/capabilities.d.ts +36 -0
- package/dist/drawing/capabilities.d.ts.map +1 -0
- package/dist/drawing/capabilities.js +1 -0
- package/dist/drawing/legacy-runtime-capability.d.ts +8 -0
- package/dist/drawing/legacy-runtime-capability.d.ts.map +1 -0
- package/dist/drawing/legacy-runtime-capability.js +92 -0
- package/dist/drawing/projection-service.d.ts +80 -0
- package/dist/drawing/projection-service.d.ts.map +1 -0
- package/dist/drawing/projection-service.js +523 -0
- package/dist/drawing/runtime-capability-descriptor.d.ts +28 -0
- package/dist/drawing/runtime-capability-descriptor.d.ts.map +1 -0
- package/dist/drawing/runtime-capability-descriptor.js +1 -0
- package/dist/drawing/scene-runtime-factory.d.ts +15 -0
- package/dist/drawing/scene-runtime-factory.d.ts.map +1 -0
- package/dist/drawing/scene-runtime-factory.js +27 -0
- package/dist/drawing/session-controller.d.ts +53 -0
- package/dist/drawing/session-controller.d.ts.map +1 -0
- package/dist/drawing/session-controller.js +339 -0
- package/dist/drawing/workspace-events.d.ts +66 -0
- package/dist/drawing/workspace-events.d.ts.map +1 -0
- package/dist/drawing/workspace-events.js +12 -0
- package/dist/drawing/workspace-runtime.d.ts +60 -0
- package/dist/drawing/workspace-runtime.d.ts.map +1 -0
- package/dist/drawing/workspace-runtime.js +328 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/runtime.d.ts +29 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +97 -1
- package/dist/toolbar/standard-toolbar-styles.d.ts.map +1 -1
- package/dist/toolbar/standard-toolbar-styles.js +18 -0
- package/dist/toolbar/standard-toolbar.d.ts +4 -2
- package/dist/toolbar/standard-toolbar.d.ts.map +1 -1
- package/dist/toolbar/standard-toolbar.js +187 -31
- package/dist/toolbar/toolbar-icons.d.ts +26 -0
- package/dist/toolbar/toolbar-icons.d.ts.map +1 -1
- package/dist/toolbar/toolbar-icons.js +13 -0
- package/dist/toolbar/toolbar-tools.d.ts +6 -1
- package/dist/toolbar/toolbar-tools.d.ts.map +1 -1
- package/dist/toolbar/toolbar-tools.js +6 -0
- package/dist/types.d.ts +7 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { serializeCanonicalScene } from '@baron1996/kline-scene-schema';
|
|
2
1
|
import { SUPPORTED_OVERLAYS } from '@baron1996/klinecharts-adapter';
|
|
3
2
|
import { registerRuntimeTeardown } from '../lifecycle.js';
|
|
4
3
|
import { createToolbarIcon } from './toolbar-icons.js';
|
|
@@ -16,6 +15,16 @@ function htmlHexColorToSceneRgba(value) {
|
|
|
16
15
|
const blue = Number.parseInt(match[3], 16);
|
|
17
16
|
return `rgba(${red}, ${green}, ${blue}, 1)`;
|
|
18
17
|
}
|
|
18
|
+
function downloadArtifact(runtime, fileName) {
|
|
19
|
+
const artifact = runtime.exportArtifact(fileName);
|
|
20
|
+
const blob = new Blob([artifact.bytes], { type: artifact.mediaType });
|
|
21
|
+
const url = URL.createObjectURL(blob);
|
|
22
|
+
const anchor = document.createElement('a');
|
|
23
|
+
anchor.href = url;
|
|
24
|
+
anchor.download = fileName;
|
|
25
|
+
anchor.click();
|
|
26
|
+
URL.revokeObjectURL(url);
|
|
27
|
+
}
|
|
19
28
|
function createIconButton(presentation, action) {
|
|
20
29
|
const element = document.createElement('button');
|
|
21
30
|
element.type = 'button';
|
|
@@ -107,16 +116,6 @@ function createTooltip(viewport, tooltipId) {
|
|
|
107
116
|
},
|
|
108
117
|
};
|
|
109
118
|
}
|
|
110
|
-
function downloadScene(runtime, fileName) {
|
|
111
|
-
const bytes = serializeCanonicalScene(runtime.exportScene());
|
|
112
|
-
const blob = new Blob([bytes], { type: 'application/json' });
|
|
113
|
-
const url = URL.createObjectURL(blob);
|
|
114
|
-
const anchor = document.createElement('a');
|
|
115
|
-
anchor.href = url;
|
|
116
|
-
anchor.download = fileName;
|
|
117
|
-
anchor.click();
|
|
118
|
-
URL.revokeObjectURL(url);
|
|
119
|
-
}
|
|
120
119
|
function setActiveOverlayButton(buttons, activeButton) {
|
|
121
120
|
for (const button of buttons) {
|
|
122
121
|
button.setAttribute('aria-pressed', String(button === activeButton));
|
|
@@ -153,6 +152,9 @@ function createInputControl(labelText, action, type) {
|
|
|
153
152
|
}
|
|
154
153
|
/** 创建不含撤销/重做的标准离线编辑工具栏。 */
|
|
155
154
|
export function createStandardToolbar(container, runtime, options = {}) {
|
|
155
|
+
const descriptor = runtime.getRuntimeCapabilityDescriptor(options.hostActions === undefined ? {} : { hostActions: options.hostActions });
|
|
156
|
+
const defaultFileName = options.downloadFileName
|
|
157
|
+
?? descriptor.exportArtifact.defaultFileName;
|
|
156
158
|
const toolbarId = nextToolbarId++;
|
|
157
159
|
const root = document.createElement('div');
|
|
158
160
|
root.className = 'baron-kline-toolbar';
|
|
@@ -180,10 +182,35 @@ export function createStandardToolbar(container, runtime, options = {}) {
|
|
|
180
182
|
{ value: 'linear', label: '线性' },
|
|
181
183
|
{ value: 'logarithmic', label: '对数' },
|
|
182
184
|
]);
|
|
185
|
+
scaleControl.select.hidden = !descriptor.valueAxis.mutable || descriptor.valueAxis.supportedScales.length < 2;
|
|
186
|
+
for (const child of Array.from(scaleControl.select.children)) {
|
|
187
|
+
child.remove();
|
|
188
|
+
}
|
|
189
|
+
for (const scale of descriptor.valueAxis.supportedScales) {
|
|
190
|
+
const option = document.createElement('option');
|
|
191
|
+
option.value = scale;
|
|
192
|
+
option.textContent = scale === 'linear' ? '线性' : '对数';
|
|
193
|
+
scaleControl.select.append(option);
|
|
194
|
+
}
|
|
183
195
|
const lineStyleControl = createSelectControl('线型', 'line-style', [
|
|
184
196
|
{ value: 'solid', label: '实线' },
|
|
185
197
|
{ value: 'dashed', label: '虚线' },
|
|
198
|
+
{ value: 'dotted', label: '点线' },
|
|
186
199
|
]);
|
|
200
|
+
const mainSeries = descriptor.mainSeriesPresentation;
|
|
201
|
+
const mainSeriesOptions = mainSeries === null
|
|
202
|
+
? []
|
|
203
|
+
: mainSeries.presentations.map((presentation) => ({
|
|
204
|
+
value: presentation.type,
|
|
205
|
+
label: presentationLabel(presentation.type),
|
|
206
|
+
presentation: structuredClone(presentation),
|
|
207
|
+
}));
|
|
208
|
+
const mainSeriesControl = mainSeries === null
|
|
209
|
+
? null
|
|
210
|
+
: createSelectControl('主序列', 'main-series', mainSeriesOptions);
|
|
211
|
+
if (mainSeries !== null && mainSeriesControl !== null) {
|
|
212
|
+
mainSeriesControl.select.value = mainSeries.activeType;
|
|
213
|
+
}
|
|
187
214
|
const lineSizeControl = createInputControl('线宽', 'line-size', 'number');
|
|
188
215
|
lineSizeControl.input.min = '0.5';
|
|
189
216
|
lineSizeControl.input.max = '10';
|
|
@@ -191,17 +218,14 @@ export function createStandardToolbar(container, runtime, options = {}) {
|
|
|
191
218
|
lineSizeControl.input.value = '1';
|
|
192
219
|
const lineColorControl = createInputControl('线色', 'line-color', 'color');
|
|
193
220
|
lineColorControl.input.value = '#2962ff';
|
|
194
|
-
|
|
195
|
-
.find((pane) => pane.kind === 'candle')
|
|
196
|
-
?.yAxes.find((axis) => axis.role === 'primary');
|
|
197
|
-
scaleControl.select.value = primaryAxis?.scale ?? 'linear';
|
|
221
|
+
scaleControl.select.value = descriptor.valueAxis.activeScale;
|
|
198
222
|
const applySelectedLineStyle = (change) => {
|
|
199
|
-
const id = runtime.
|
|
200
|
-
const overlay = id === undefined ? undefined : runtime.
|
|
223
|
+
const id = runtime.getSelectedDrawingId();
|
|
224
|
+
const overlay = id === undefined ? undefined : runtime.getDrawing(id);
|
|
201
225
|
if (id === undefined || overlay === undefined) {
|
|
202
226
|
return;
|
|
203
227
|
}
|
|
204
|
-
runtime.
|
|
228
|
+
runtime.updateDrawingStyles(id, {
|
|
205
229
|
...structuredClone(overlay.styles),
|
|
206
230
|
line: {
|
|
207
231
|
...structuredClone(overlay.styles.line),
|
|
@@ -210,7 +234,7 @@ export function createStandardToolbar(container, runtime, options = {}) {
|
|
|
210
234
|
});
|
|
211
235
|
};
|
|
212
236
|
const handleScaleChange = async () => {
|
|
213
|
-
await runtime.
|
|
237
|
+
await runtime.setValueAxisScale(scaleControl.select.value);
|
|
214
238
|
};
|
|
215
239
|
const handleLineStyleChange = () => {
|
|
216
240
|
applySelectedLineStyle({
|
|
@@ -223,41 +247,155 @@ export function createStandardToolbar(container, runtime, options = {}) {
|
|
|
223
247
|
const handleLineColorChange = () => {
|
|
224
248
|
applySelectedLineStyle({ color: htmlHexColorToSceneRgba(lineColorControl.input.value) });
|
|
225
249
|
};
|
|
250
|
+
const handleTextChange = () => {
|
|
251
|
+
const id = runtime.getSelectedDrawingId();
|
|
252
|
+
const drawing = id === undefined ? undefined : runtime.getDrawing(id);
|
|
253
|
+
if (id === undefined ||
|
|
254
|
+
drawing === undefined ||
|
|
255
|
+
!(drawing.type === 'simpleTag' ||
|
|
256
|
+
drawing.type === 'simpleAnnotation' ||
|
|
257
|
+
drawing.type === 'callout' ||
|
|
258
|
+
drawing.type === 'text')) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
runtime.updateDrawingText(id, textInput.value);
|
|
262
|
+
};
|
|
226
263
|
scaleControl.select.addEventListener('change', handleScaleChange);
|
|
227
264
|
lineStyleControl.select.addEventListener('change', handleLineStyleChange);
|
|
228
265
|
lineSizeControl.input.addEventListener('change', handleLineSizeChange);
|
|
229
266
|
lineColorControl.input.addEventListener('change', handleLineColorChange);
|
|
230
|
-
|
|
267
|
+
textInput.addEventListener('change', handleTextChange);
|
|
268
|
+
cleanupCallbacks.push(() => scaleControl.select.removeEventListener('change', handleScaleChange), () => lineStyleControl.select.removeEventListener('change', handleLineStyleChange), () => lineSizeControl.input.removeEventListener('change', handleLineSizeChange), () => lineColorControl.input.removeEventListener('change', handleLineColorChange), () => textInput.removeEventListener('change', handleTextChange));
|
|
269
|
+
const useContextMenu = options.editControlsPlacement === 'context-menu';
|
|
270
|
+
if (useContextMenu && options.contextMenuTarget === undefined) {
|
|
271
|
+
throw new TypeError('STANDARD_TOOLBAR_CONTEXT_MENU_TARGET_REQUIRED: ' +
|
|
272
|
+
'editControlsPlacement "context-menu" requires contextMenuTarget.');
|
|
273
|
+
}
|
|
274
|
+
const contextMenuTarget = options.contextMenuTarget;
|
|
275
|
+
const editLabels = [
|
|
276
|
+
scaleControl.label,
|
|
277
|
+
lineStyleControl.label,
|
|
278
|
+
lineSizeControl.label,
|
|
279
|
+
lineColorControl.label,
|
|
280
|
+
];
|
|
281
|
+
if (mainSeriesControl !== null &&
|
|
282
|
+
options.mainSeriesPresentationControl === 'enabled') {
|
|
283
|
+
editLabels.push(mainSeriesControl.label);
|
|
284
|
+
}
|
|
285
|
+
// 主序列切换监听与控件放置位置无关,统一注册一次。
|
|
286
|
+
if (mainSeries !== null &&
|
|
287
|
+
mainSeriesControl !== null &&
|
|
288
|
+
options.mainSeriesPresentationControl === 'enabled') {
|
|
289
|
+
const handleMainSeriesChange = () => {
|
|
290
|
+
const presentation = mainSeries?.presentations.find((candidate) => candidate.type === mainSeriesControl.select.value);
|
|
291
|
+
if (presentation === undefined) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const result = runtime.setMainSeriesPresentation(presentation);
|
|
295
|
+
mainSeriesControl.select.value = result.activeType;
|
|
296
|
+
};
|
|
297
|
+
mainSeriesControl.select.addEventListener('change', handleMainSeriesChange);
|
|
298
|
+
cleanupCallbacks.push(() => mainSeriesControl.select.removeEventListener('change', handleMainSeriesChange));
|
|
299
|
+
}
|
|
300
|
+
if (useContextMenu && contextMenuTarget !== undefined) {
|
|
301
|
+
const menu = document.createElement('div');
|
|
302
|
+
menu.className = 'baron-kline-context-menu';
|
|
303
|
+
menu.setAttribute('role', 'group');
|
|
304
|
+
menu.setAttribute('aria-label', '坐标与样式');
|
|
305
|
+
menu.hidden = true;
|
|
306
|
+
menu.append(...editLabels);
|
|
307
|
+
document.body.append(menu);
|
|
308
|
+
const hideContextMenu = () => {
|
|
309
|
+
menu.hidden = true;
|
|
310
|
+
menu.classList.remove('baron-kline-context-menu--visible');
|
|
311
|
+
};
|
|
312
|
+
const handleContextMenu = (event) => {
|
|
313
|
+
const rect = contextMenuTarget.getBoundingClientRect();
|
|
314
|
+
const point = {
|
|
315
|
+
x: event.clientX - rect.left,
|
|
316
|
+
y: event.clientY - rect.top,
|
|
317
|
+
};
|
|
318
|
+
// 只有图表空白处右键才弹出编辑菜单;命中 Drawing 时不接管。
|
|
319
|
+
if (runtime.hitTestDrawing(point) !== null) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
event.preventDefault();
|
|
323
|
+
menu.hidden = false;
|
|
324
|
+
menu.classList.add('baron-kline-context-menu--visible');
|
|
325
|
+
const gap = 8;
|
|
326
|
+
menu.style.left = `${Math.max(0, Math.min(event.clientX, window.innerWidth - menu.offsetWidth - gap))}px`;
|
|
327
|
+
menu.style.top = `${Math.max(0, Math.min(event.clientY, window.innerHeight - menu.offsetHeight - gap))}px`;
|
|
328
|
+
};
|
|
329
|
+
const handlePointerDown = (event) => {
|
|
330
|
+
if (!menu.contains(event.target)) {
|
|
331
|
+
hideContextMenu();
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
const handleKeyDown = (event) => {
|
|
335
|
+
if (event.key === 'Escape') {
|
|
336
|
+
hideContextMenu();
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
contextMenuTarget.addEventListener('contextmenu', handleContextMenu);
|
|
340
|
+
document.addEventListener('pointerdown', handlePointerDown);
|
|
341
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
342
|
+
window.addEventListener('resize', hideContextMenu);
|
|
343
|
+
window.addEventListener('scroll', hideContextMenu, true);
|
|
344
|
+
cleanupCallbacks.push(() => {
|
|
345
|
+
contextMenuTarget.removeEventListener('contextmenu', handleContextMenu);
|
|
346
|
+
document.removeEventListener('pointerdown', handlePointerDown);
|
|
347
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
348
|
+
window.removeEventListener('resize', hideContextMenu);
|
|
349
|
+
window.removeEventListener('scroll', hideContextMenu, true);
|
|
350
|
+
menu.remove();
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
const drawableTypes = (descriptor.drawingTypes.length === 0
|
|
354
|
+
? SUPPORTED_OVERLAYS
|
|
355
|
+
: descriptor.drawingTypes);
|
|
231
356
|
for (const group of TOOLBAR_GROUPS) {
|
|
357
|
+
if (group.id === 'edit' && useContextMenu) {
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
232
360
|
const groupElement = document.createElement('div');
|
|
233
361
|
groupElement.className = 'baron-kline-toolbar__group';
|
|
234
362
|
groupElement.dataset.toolbarGroup = group.id;
|
|
235
363
|
groupElement.setAttribute('role', 'group');
|
|
236
364
|
groupElement.setAttribute('aria-label', group.label);
|
|
237
365
|
if (group.id === 'edit') {
|
|
238
|
-
groupElement.append(
|
|
366
|
+
groupElement.append(...editLabels);
|
|
239
367
|
}
|
|
240
368
|
else if (group.id === 'action') {
|
|
241
369
|
for (const presentation of TOOLBAR_ACTIONS) {
|
|
242
370
|
const action = presentation.action === 'delete'
|
|
243
371
|
? () => {
|
|
244
|
-
const id = runtime.
|
|
372
|
+
const id = runtime.getSelectedDrawingId();
|
|
245
373
|
if (id === undefined) {
|
|
246
374
|
return;
|
|
247
375
|
}
|
|
248
|
-
const overlay = runtime.
|
|
376
|
+
const overlay = runtime.getDrawing(id);
|
|
249
377
|
if (overlay !== undefined && !overlay.locked) {
|
|
250
378
|
if ((options.deleteBehavior ?? 'direct') === 'request') {
|
|
251
|
-
runtime.
|
|
379
|
+
runtime.requestDrawingDelete(id);
|
|
252
380
|
}
|
|
253
381
|
else {
|
|
254
|
-
runtime.
|
|
382
|
+
runtime.removeDrawing(id);
|
|
255
383
|
}
|
|
256
384
|
}
|
|
257
385
|
}
|
|
258
|
-
:
|
|
259
|
-
|
|
260
|
-
|
|
386
|
+
: presentation.action === 'clear-all'
|
|
387
|
+
? () => {
|
|
388
|
+
// 清空全部 Drawing;锁定的 Drawing 保持既有“不接受 mutation”契约。
|
|
389
|
+
for (const drawing of runtime.listDrawings()) {
|
|
390
|
+
if (!drawing.locked) {
|
|
391
|
+
runtime.removeDrawing(drawing.id);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
runtime.selectDrawing(null);
|
|
395
|
+
}
|
|
396
|
+
: () => {
|
|
397
|
+
downloadArtifact(runtime, defaultFileName);
|
|
398
|
+
};
|
|
261
399
|
const button = createIconButton(presentation, action);
|
|
262
400
|
button.element.dataset.action = presentation.action;
|
|
263
401
|
groupElement.append(button.element);
|
|
@@ -270,21 +408,21 @@ export function createStandardToolbar(container, runtime, options = {}) {
|
|
|
270
408
|
button.dataset.hostAction = hostAction.actionId;
|
|
271
409
|
button.textContent = hostAction.label;
|
|
272
410
|
button.setAttribute('aria-label', hostAction.label);
|
|
273
|
-
const action = () => runtime.requestHostAction(hostAction.actionId, runtime.
|
|
411
|
+
const action = () => runtime.requestHostAction(hostAction.actionId, runtime.getSelectedDrawingId() ?? null);
|
|
274
412
|
button.addEventListener('click', action);
|
|
275
413
|
groupElement.append(button);
|
|
276
414
|
cleanupCallbacks.push(() => button.removeEventListener('click', action));
|
|
277
415
|
}
|
|
278
416
|
}
|
|
279
417
|
else {
|
|
280
|
-
for (const overlayType of
|
|
418
|
+
for (const overlayType of drawableTypes) {
|
|
281
419
|
const presentation = OVERLAY_TOOL_PRESENTATIONS[overlayType];
|
|
282
420
|
if (presentation.group !== group.id) {
|
|
283
421
|
continue;
|
|
284
422
|
}
|
|
285
423
|
let buttonElement;
|
|
286
424
|
const action = () => {
|
|
287
|
-
runtime.
|
|
425
|
+
runtime.startDrawing(overlayType, TEXT_OVERLAY_TYPES.has(overlayType)
|
|
288
426
|
? { text: textInput.value }
|
|
289
427
|
: {});
|
|
290
428
|
setActiveOverlayButton(overlayButtons, buttonElement);
|
|
@@ -329,3 +467,21 @@ export function createStandardToolbar(container, runtime, options = {}) {
|
|
|
329
467
|
unregisterRuntime = registerRuntimeTeardown(runtime, () => toolbar.destroy());
|
|
330
468
|
return toolbar;
|
|
331
469
|
}
|
|
470
|
+
function presentationLabel(type) {
|
|
471
|
+
switch (type) {
|
|
472
|
+
case 'candle_solid':
|
|
473
|
+
return '实心蜡烛';
|
|
474
|
+
case 'candle_stroke':
|
|
475
|
+
return '描边蜡烛';
|
|
476
|
+
case 'candle_up_stroke':
|
|
477
|
+
return '上涨描边';
|
|
478
|
+
case 'candle_down_stroke':
|
|
479
|
+
return '下跌描边';
|
|
480
|
+
case 'ohlc':
|
|
481
|
+
return 'OHLC';
|
|
482
|
+
case 'area':
|
|
483
|
+
return '收盘价折线';
|
|
484
|
+
default:
|
|
485
|
+
return type;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
@@ -452,6 +452,32 @@ declare const ICON_SPECS: {
|
|
|
452
452
|
readonly d: "M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3";
|
|
453
453
|
};
|
|
454
454
|
}];
|
|
455
|
+
readonly clearAll: readonly [{
|
|
456
|
+
readonly name: "path";
|
|
457
|
+
readonly attributes: {
|
|
458
|
+
readonly d: "M4 7l16 0";
|
|
459
|
+
};
|
|
460
|
+
}, {
|
|
461
|
+
readonly name: "path";
|
|
462
|
+
readonly attributes: {
|
|
463
|
+
readonly d: "M10 11l4 4";
|
|
464
|
+
};
|
|
465
|
+
}, {
|
|
466
|
+
readonly name: "path";
|
|
467
|
+
readonly attributes: {
|
|
468
|
+
readonly d: "M14 11l-4 4";
|
|
469
|
+
};
|
|
470
|
+
}, {
|
|
471
|
+
readonly name: "path";
|
|
472
|
+
readonly attributes: {
|
|
473
|
+
readonly d: "M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12";
|
|
474
|
+
};
|
|
475
|
+
}, {
|
|
476
|
+
readonly name: "path";
|
|
477
|
+
readonly attributes: {
|
|
478
|
+
readonly d: "M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3";
|
|
479
|
+
};
|
|
480
|
+
}];
|
|
455
481
|
readonly fileExport: readonly [{
|
|
456
482
|
readonly name: "path";
|
|
457
483
|
readonly attributes: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar-icons.d.ts","sourceRoot":"","sources":["../../src/toolbar/toolbar-icons.ts"],"names":[],"mappings":"AAcA,QAAA,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"toolbar-icons.d.ts","sourceRoot":"","sources":["../../src/toolbar/toolbar-icons.ts"],"names":[],"mappings":"AAcA,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqL2C,CAAC;AAE5D,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,UAAU,CAAC;AAEtD,4CAA4C;AAC5C,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,aAAa,CAoBtE"}
|
|
@@ -162,6 +162,19 @@ const ICON_SPECS = {
|
|
|
162
162
|
attributes: { d: 'M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3' },
|
|
163
163
|
},
|
|
164
164
|
],
|
|
165
|
+
clearAll: [
|
|
166
|
+
{ name: 'path', attributes: { d: 'M4 7l16 0' } },
|
|
167
|
+
{ name: 'path', attributes: { d: 'M10 11l4 4' } },
|
|
168
|
+
{ name: 'path', attributes: { d: 'M14 11l-4 4' } },
|
|
169
|
+
{
|
|
170
|
+
name: 'path',
|
|
171
|
+
attributes: { d: 'M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12' },
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: 'path',
|
|
175
|
+
attributes: { d: 'M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3' },
|
|
176
|
+
},
|
|
177
|
+
],
|
|
165
178
|
fileExport: [
|
|
166
179
|
{ name: 'path', attributes: { d: 'M14 3v4a1 1 0 0 0 1 1h4' } },
|
|
167
180
|
{
|
|
@@ -11,7 +11,7 @@ export interface ToolbarToolPresentation {
|
|
|
11
11
|
readonly icon: ToolbarIconName;
|
|
12
12
|
}
|
|
13
13
|
export interface ToolbarActionPresentation {
|
|
14
|
-
readonly action: 'delete' | 'export';
|
|
14
|
+
readonly action: 'delete' | 'clear-all' | 'export';
|
|
15
15
|
readonly label: string;
|
|
16
16
|
readonly group: 'action';
|
|
17
17
|
readonly icon: ToolbarIconName;
|
|
@@ -49,6 +49,11 @@ export declare const TOOLBAR_ACTIONS: readonly [{
|
|
|
49
49
|
readonly label: "删除选中标注";
|
|
50
50
|
readonly group: "action";
|
|
51
51
|
readonly icon: "trash";
|
|
52
|
+
}, {
|
|
53
|
+
readonly action: "clear-all";
|
|
54
|
+
readonly label: "清空全部标注";
|
|
55
|
+
readonly group: "action";
|
|
56
|
+
readonly icon: "clearAll";
|
|
52
57
|
}, {
|
|
53
58
|
readonly action: "export";
|
|
54
59
|
readonly label: "导出场景";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar-tools.d.ts","sourceRoot":"","sources":["../../src/toolbar/toolbar-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,MAAM,cAAc,GACvB,YAAY,GACZ,UAAU,GACV,OAAO,GACP,UAAU,GACV,YAAY,GACZ,OAAO,GACP,MAAM,GACN,QAAQ,CAAC;AAEZ,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,cAAc,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC;IAC3D,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;CAC/B;AAED,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"toolbar-tools.d.ts","sourceRoot":"","sources":["../../src/toolbar/toolbar-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,MAAM,cAAc,GACvB,YAAY,GACZ,UAAU,GACV,OAAO,GACP,UAAU,GACV,YAAY,GACZ,OAAO,GACP,MAAM,GACN,QAAQ,CAAC;AAEZ,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,cAAc,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC;IAC3D,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;CAC/B;AAED,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;CAC/B;AAED,4BAA4B;AAC5B,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;EASiB,CAAC;AAE7C,qCAAqC;AACrC,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAChD,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,CAgHrD,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;EAmB6B,CAAC;AAE1D,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,oBAAoB,CAK/D,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ChartScene, JsonObject, SceneIssue, SceneOverlay } from '@baron1996/kline-scene-schema';
|
|
2
2
|
import type { SUPPORTED_OVERLAYS } from '@baron1996/klinecharts-adapter';
|
|
3
|
+
import type { HostActionDescriptor } from './drawing/runtime-capability-descriptor.js';
|
|
3
4
|
export type SupportedOverlayType = (typeof SUPPORTED_OVERLAYS)[number];
|
|
4
5
|
export interface KLineSceneRuntimeEventEnvelope {
|
|
5
6
|
readonly sceneVersion: 1;
|
|
@@ -80,10 +81,12 @@ export interface StartOverlayDrawingOptions {
|
|
|
80
81
|
export interface StandardToolbarOptions {
|
|
81
82
|
readonly downloadFileName?: string;
|
|
82
83
|
readonly deleteBehavior?: 'direct' | 'request';
|
|
83
|
-
readonly hostActions?: readonly
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
readonly hostActions?: readonly HostActionDescriptor[];
|
|
85
|
+
readonly mainSeriesPresentationControl?: 'hidden' | 'enabled';
|
|
86
|
+
/** 编辑控件(价格轴/线型/线宽/线色/主序列)的放置位置:常驻工具栏(默认)或图表右键上下文菜单。 */
|
|
87
|
+
readonly editControlsPlacement?: 'toolbar' | 'context-menu';
|
|
88
|
+
/** editControlsPlacement 为 context-menu 时,右键监听的图表容器。 */
|
|
89
|
+
readonly contextMenuTarget?: HTMLElement;
|
|
87
90
|
}
|
|
88
91
|
export interface StandardToolbar {
|
|
89
92
|
readonly element: HTMLElement;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE,MAAM,WAAW,8BAA8B;IAC9C,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAC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"license": "Apache-2.0",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@baron1996/kline-scene-schema": "0.
|
|
43
|
-
"@baron1996/klinecharts-adapter": "0.
|
|
42
|
+
"@baron1996/kline-scene-schema": "0.4.0",
|
|
43
|
+
"@baron1996/klinecharts-adapter": "0.4.0",
|
|
44
|
+
"@js-temporal/polyfill": "0.5.1"
|
|
44
45
|
}
|
|
45
46
|
}
|