@particle-academy/fancy-cms-ui 0.1.0 → 0.2.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/dist/editor.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { C as Canvas, a as CanvasProps, E as Editor, b as EditorAction, c as EditorApi, d as EditorProps, e as EditorState, I as Inspector, f as InspectorProps, L as LayersPanel, g as LayersPanelProps, i as editorReduce, j as initEditor, u as useEditor } from './useEditor-DLH7hU6G.cjs';
1
+ export { C as Canvas, a as CanvasProps, E as Editor, b as EditorAction, c as EditorApi, d as EditorProps, e as EditorState, I as Inspector, f as InspectorProps, L as LayersPanel, g as LayersPanelProps, i as editorReduce, j as initEditor, u as useEditor } from './useEditor-CVT8sTum.cjs';
2
2
  import { ReactNode, ReactElement } from 'react';
3
3
  import { P as PageDoc, h as ElementRegistry, g as DataContext, N as Node, p as StyleProps, L as LayoutMode } from './registry-D5y5IgCR.cjs';
4
4
 
package/dist/editor.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { C as Canvas, a as CanvasProps, E as Editor, b as EditorAction, c as EditorApi, d as EditorProps, e as EditorState, I as Inspector, f as InspectorProps, L as LayersPanel, g as LayersPanelProps, i as editorReduce, j as initEditor, u as useEditor } from './useEditor-qmF9n2e6.js';
1
+ export { C as Canvas, a as CanvasProps, E as Editor, b as EditorAction, c as EditorApi, d as EditorProps, e as EditorState, I as Inspector, f as InspectorProps, L as LayersPanel, g as LayersPanelProps, i as editorReduce, j as initEditor, u as useEditor } from './useEditor-CV5jFAgo.js';
2
2
  import { ReactNode, ReactElement } from 'react';
3
3
  import { P as PageDoc, h as ElementRegistry, g as DataContext, N as Node, p as StyleProps, L as LayoutMode } from './registry-D5y5IgCR.js';
4
4
 
package/dist/editor.js CHANGED
@@ -1,5 +1,5 @@
1
- import { useEditor, keyBetween } from './chunk-N22BQAY3.js';
2
- export { Canvas, Editor, Inspector, LayersPanel, editorReduce, initEditor, useEditor } from './chunk-N22BQAY3.js';
1
+ import { useEditor, useLatestRef, keyBetween } from './chunk-XQ3KHMBJ.js';
2
+ export { Canvas, Editor, Inspector, LayersPanel, editorReduce, initEditor, useEditor } from './chunk-XQ3KHMBJ.js';
3
3
  import { isBinding, childrenOf, CmsPage, defaultRegistry } from './chunk-GOXVGEKU.js';
4
4
  import { useState, useRef, useEffect, useCallback, useLayoutEffect } from 'react';
5
5
  import { ContextMenu } from '@particle-academy/react-fancy';
@@ -391,7 +391,8 @@ function EditablePage({
391
391
  const [box, setBox] = useState(null);
392
392
  const { selection } = ed.state;
393
393
  const selNode = selection ? ed.state.doc.nodes[selection] : null;
394
- useEffect(() => onSelect?.(selection), [selection, onSelect]);
394
+ const onSelectRef = useLatestRef(onSelect);
395
+ useEffect(() => onSelectRef.current?.(selection), [selection, onSelectRef]);
395
396
  useEffect(() => {
396
397
  const onKey = (e) => setRevealed(e.ctrlKey && e.shiftKey);
397
398
  const onBlur = () => setRevealed(false);
@@ -413,13 +414,15 @@ function EditablePage({
413
414
  applyTransform(el, t);
414
415
  });
415
416
  }, [transforms, ed.state.doc]);
417
+ const onProgressRef = useLatestRef(onProgress);
418
+ const hasProgress = !!onProgress;
416
419
  useEffect(() => {
417
420
  const spacer = spacerRef.current;
418
- if (!spacer || !onProgress) return;
421
+ if (!spacer || !hasProgress) return;
419
422
  const compute = () => {
420
423
  const len2 = spacer.offsetHeight - window.innerHeight;
421
424
  const top = spacer.getBoundingClientRect().top;
422
- onProgress(len2 > 0 ? Math.min(1, Math.max(0, -top / len2)) : 0);
425
+ onProgressRef.current?.(len2 > 0 ? Math.min(1, Math.max(0, -top / len2)) : 0);
423
426
  };
424
427
  compute();
425
428
  window.addEventListener("scroll", compute, { passive: true });
@@ -428,7 +431,7 @@ function EditablePage({
428
431
  window.removeEventListener("scroll", compute);
429
432
  window.removeEventListener("resize", compute);
430
433
  };
431
- }, [onProgress, frames]);
434
+ }, [hasProgress, onProgressRef, frames]);
432
435
  const measureBox = useCallback(() => {
433
436
  if (!editing || !selection || !pageRef.current) return setBox(null);
434
437
  const el = pageRef.current.querySelector(`[data-cms="${cssEscape(selection)}"]`);