@particle-academy/fancy-cms-ui 0.1.0 → 0.1.1
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/{chunk-N22BQAY3.js → chunk-524NYOHK.js} +13 -5
- package/dist/chunk-524NYOHK.js.map +1 -0
- package/dist/editor.cjs +17 -6
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.js +9 -6
- package/dist/editor.js.map +1 -1
- package/dist/index.cjs +10 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -1
- package/dist/chunk-N22BQAY3.js.map +0 -1
package/dist/editor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useEditor, keyBetween } from './chunk-
|
|
2
|
-
export { Canvas, Editor, Inspector, LayersPanel, editorReduce, initEditor, useEditor } from './chunk-
|
|
1
|
+
import { useEditor, useLatestRef, keyBetween } from './chunk-524NYOHK.js';
|
|
2
|
+
export { Canvas, Editor, Inspector, LayersPanel, editorReduce, initEditor, useEditor } from './chunk-524NYOHK.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
|
-
|
|
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 || !
|
|
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
|
-
|
|
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
|
-
}, [
|
|
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)}"]`);
|