@baron1996/klinecharts-runtime 0.9.14 → 0.9.15

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 CHANGED
@@ -4,7 +4,7 @@ Browser editing runtime and standard annotation toolbar for deterministic KLineC
4
4
  ChartScene files.
5
5
 
6
6
  ```bash
7
- npm install --save-exact @baron1996/kline-scene-schema@0.9.14 @baron1996/klinecharts-runtime@0.9.14
7
+ npm install --save-exact @baron1996/kline-scene-schema@0.9.15 @baron1996/klinecharts-runtime@0.9.15
8
8
  ```
9
9
 
10
10
  ```ts
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** Web Runtime npm 包版本;ChartScene runtimeVersion 是独立的数据契约版本。 */
2
- export declare const WEB_RUNTIME_PACKAGE_VERSION: "0.9.14";
2
+ export declare const WEB_RUNTIME_PACKAGE_VERSION: "0.9.15";
3
3
  export { SUPPORTED_OVERLAYS } from '@baron1996/klinecharts-adapter';
4
4
  export * from './cross-period/coordinator.js';
5
5
  export * from './drawing/capabilities.js';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /** Web Runtime npm 包版本;ChartScene runtimeVersion 是独立的数据契约版本。 */
2
- export const WEB_RUNTIME_PACKAGE_VERSION = '0.9.14';
2
+ export const WEB_RUNTIME_PACKAGE_VERSION = '0.9.15';
3
3
  export { SUPPORTED_OVERLAYS } from '@baron1996/klinecharts-adapter';
4
4
  export * from './cross-period/coordinator.js';
5
5
  export * from './drawing/capabilities.js';
@@ -1,8 +1,8 @@
1
1
  import type { DrawingRuntimeCapability } from '../drawing/capabilities.js';
2
2
  import type { DrawingFloatingToolbar, DrawingFloatingToolbarOptions } from '../types.js';
3
3
  /**
4
- * 创建选中 Drawing 的对象级浮动工具栏。工具栏使用 body portal,避免修改图表引擎 DOM;
5
- * 拖动位置只保存在当前实例内,刷新后回到图表顶部中央。
4
+ * 创建选中 Drawing 的对象级浮动工具栏。普通模式使用 body portal,目标图表所属工作区
5
+ * 进入元素全屏时迁入对应全屏子树;拖动位置只保存在当前实例内,刷新后回到图表顶部中央。
6
6
  */
7
7
  export declare function createDrawingFloatingToolbar(target: HTMLElement, runtime: DrawingRuntimeCapability, options?: DrawingFloatingToolbarOptions): DrawingFloatingToolbar;
8
8
  //# sourceMappingURL=drawing-floating-toolbar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"drawing-floating-toolbar.d.ts","sourceRoot":"","sources":["../../src/toolbar/drawing-floating-toolbar.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,MAAM,aAAa,CAAC;AAgFrB;;;GAGG;AACH,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,wBAAwB,EACjC,OAAO,GAAE,6BAAkC,GACzC,sBAAsB,CA6WxB"}
1
+ {"version":3,"file":"drawing-floating-toolbar.d.ts","sourceRoot":"","sources":["../../src/toolbar/drawing-floating-toolbar.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,MAAM,aAAa,CAAC;AAgFrB;;;GAGG;AACH,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,wBAAwB,EACjC,OAAO,GAAE,6BAAkC,GACzC,sBAAsB,CA4XxB"}
@@ -62,8 +62,8 @@ function selectedDrawing(runtime) {
62
62
  return id === undefined ? undefined : runtime.getDrawing(id);
63
63
  }
64
64
  /**
65
- * 创建选中 Drawing 的对象级浮动工具栏。工具栏使用 body portal,避免修改图表引擎 DOM;
66
- * 拖动位置只保存在当前实例内,刷新后回到图表顶部中央。
65
+ * 创建选中 Drawing 的对象级浮动工具栏。普通模式使用 body portal,目标图表所属工作区
66
+ * 进入元素全屏时迁入对应全屏子树;拖动位置只保存在当前实例内,刷新后回到图表顶部中央。
67
67
  */
68
68
  export function createDrawingFloatingToolbar(target, runtime, options = {}) {
69
69
  const style = document.createElement('style');
@@ -125,7 +125,13 @@ export function createDrawingFloatingToolbar(target, runtime, options = {}) {
125
125
  status.hidden = true;
126
126
  root.append(grip, type, createSeparator(), color, lineStyle.label, lineWidth.label, textInput, createSeparator(), lock, remove, status);
127
127
  document.head.append(style);
128
- document.body.append(root);
128
+ const resolvePortalHost = () => {
129
+ const fullscreenElement = document.fullscreenElement;
130
+ return fullscreenElement !== null && fullscreenElement.contains(target)
131
+ ? fullscreenElement
132
+ : document.body;
133
+ };
134
+ resolvePortalHost().append(root);
129
135
  let destroyed = false;
130
136
  let userPositioned = false;
131
137
  let dragging = null;
@@ -327,8 +333,16 @@ export function createDrawingFloatingToolbar(target, runtime, options = {}) {
327
333
  grip.addEventListener('pointercancel', finishDrag);
328
334
  const unsubscribe = runtime.subscribeDrawingChanges(render);
329
335
  const handleViewportChange = () => clampCurrentPosition();
336
+ const handleFullscreenChange = () => {
337
+ const portalHost = resolvePortalHost();
338
+ if (root.parentNode !== portalHost) {
339
+ portalHost.append(root);
340
+ }
341
+ clampCurrentPosition();
342
+ };
330
343
  window.addEventListener('resize', handleViewportChange);
331
344
  window.addEventListener('scroll', handleViewportChange, true);
345
+ document.addEventListener('fullscreenchange', handleFullscreenChange);
332
346
  const resizeObserver = typeof ResizeObserver === 'undefined'
333
347
  ? null
334
348
  : new ResizeObserver(handleViewportChange);
@@ -354,6 +368,7 @@ export function createDrawingFloatingToolbar(target, runtime, options = {}) {
354
368
  resizeObserver?.disconnect();
355
369
  window.removeEventListener('resize', handleViewportChange);
356
370
  window.removeEventListener('scroll', handleViewportChange, true);
371
+ document.removeEventListener('fullscreenchange', handleFullscreenChange);
357
372
  colorInput.removeEventListener('change', handleColorChange);
358
373
  lineStyle.select.removeEventListener('change', handleLineStyleChange);
359
374
  lineWidth.select.removeEventListener('change', handleLineWidthChange);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baron1996/klinecharts-runtime",
3
- "version": "0.9.14",
3
+ "version": "0.9.15",
4
4
  "description": "Web runtime for deterministic KLineCharts scenes.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -39,8 +39,8 @@
39
39
  "typecheck": "tsc -p tsconfig.json --noEmit"
40
40
  },
41
41
  "dependencies": {
42
- "@baron1996/kline-scene-schema": "0.9.14",
43
- "@baron1996/klinecharts-adapter": "0.9.14",
42
+ "@baron1996/kline-scene-schema": "0.9.15",
43
+ "@baron1996/klinecharts-adapter": "0.9.15",
44
44
  "@js-temporal/polyfill": "0.5.1"
45
45
  }
46
46
  }