@jbpark/live-editor 6.0.0 → 6.1.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/dnd/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as Panel, c as useDndChildren, d as useDndLayout, f as useDndPalette, h as DraggableItem, i as Palette, l as resolvePanelBindings, m as useDndInspector, n as Canvas, o as Field, p as useDndPanel, r as Layout, s as useDndItems, t as Dnd, u as withPanelCommit } from "../dnd-BvjEDo-x.js";
1
+ import { a as Panel, c as useDndChildren, d as useDndLayout, f as useDndPalette, h as DraggableItem, i as Palette, l as resolvePanelBindings, m as useDndInspector, n as Canvas, o as Field, p as useDndPanel, r as Layout, s as useDndItems, t as Dnd, u as withPanelCommit } from "../dnd-COjjjuD7.js";
2
2
  import { a as isStructuralFieldKind, i as getFieldKind } from "../use-field-state-iQGW0vc6.js";
3
3
  export { Canvas, DraggableItem, Field, Layout, Palette, Panel, Dnd as default, getFieldKind, isStructuralFieldKind, resolvePanelBindings, useDndChildren, useDndInspector, useDndItems, useDndLayout, useDndPalette, useDndPanel, withPanelCommit };
@@ -1,13 +1,13 @@
1
- import { C as isJSXElement, D as isJSXIdentifier, E as isJSXFragment, I as isSpreadElement, L as isStringLiteral, N as isObjectExpression, O as isJSXOpeningElement, P as isObjectProperty, S as isJSXAttribute, a as inspectDocument, at as stringLiteral, b as isExpression, ct as traverseFast, d as applyEdits, dt as parseExpression, k as isJSXSpreadAttribute, l as fillIdsFrom, n as fillSectionIds, ot as templateElement, p as nanoid, st as templateLiteral, t as createSectionPreviewCache, u as replaceIds, x as isIdentifier } from "./document-uHqw0mvr.js";
1
+ import { C as isJSXElement, D as isJSXIdentifier, E as isJSXFragment, I as isSpreadElement, L as isStringLiteral, N as isObjectExpression, O as isJSXOpeningElement, P as isObjectProperty, S as isJSXAttribute, a as inspectDocument, at as stringLiteral, b as isExpression, ct as traverseFast, d as applyEdits, dt as parseExpression, k as isJSXSpreadAttribute, l as fillIdsFrom, n as fillSectionIds, ot as templateElement, p as nanoid, st as templateLiteral, t as createSectionPreviewCache, u as replaceIds, x as isIdentifier } from "./document-BkGWDZGc.js";
2
2
  import { r as DATA_ATTR, s as RESERVED_BINDING_PROPERTIES, t as BINDING_PROP } from "./constants-st9gnJ5g.js";
3
3
  import { i as useLiveMessages } from "./messages-DrINcRdG.js";
4
4
  import { i as usePreview } from "./states-Ci1AvoQ9.js";
5
- import { _ as parseArrayExpression, a as getChildrenSignatures, b as generateCode, c as removeIndices, d as getStructuredValue, f as readNodeBindings, g as isLosslesslyEvaluable, h as extractObjectProperties, i as valueToExpression, l as findEditableChildren, m as extractNodeValue, n as updateAll, o as extract, p as canLosslesslyEvaluateSource, r as createNodeFromValue, s as moveSelectedIndices, u as getCurrentValue, v as parseValue } from "./update-BuYQJqjq.js";
5
+ import { _ as parseArrayExpression, a as getChildrenSignatures, b as generateCode, c as removeIndices, d as getStructuredValue, f as readNodeBindings, g as isLosslesslyEvaluable, h as extractObjectProperties, i as valueToExpression, l as findEditableChildren, m as extractNodeValue, n as updateAll, o as extract, p as canLosslesslyEvaluateSource, r as createNodeFromValue, s as moveSelectedIndices, u as getCurrentValue, v as parseValue } from "./update-DyFnX8yE.js";
6
6
  import { t as cn } from "./cn-CAnad2vL.js";
7
7
  import { r as preloadScripts } from "./compile-my0AjsCw.js";
8
- import { a as replaceSections, i as generateSection, r as extractSections } from "./sections-DhH_aVf5.js";
8
+ import { a as replaceSections, i as generateSection, r as extractSections } from "./sections-rD8NuRI8.js";
9
9
  import { n as Error$1, t as ErrorBoundary } from "./boundary-CySnDUs2.js";
10
- import { a as renderStableComponent, n as useCompiledModule, o as Frame, t as useDynamicTailwind } from "./use-dynamic-tailwind-B3l1qZRW.js";
10
+ import { a as renderStableComponent, n as useCompiledModule, o as Frame, t as useDynamicTailwind } from "./use-dynamic-tailwind-0nuRN57N.js";
11
11
  import { i as getFieldKind, n as FieldIdsContext, o as FieldError, r as LABELABLE_KINDS, s as fields_module_default, t as useFieldState } from "./use-field-state-iQGW0vc6.js";
12
12
  import { t as Core } from "./core-BNVuH8-l.js";
13
13
  import { Children, createContext, memo, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
@@ -1234,6 +1234,16 @@ const Sortable = ({ id, children, selected, onClick, onDelete, onCopy, onMoveUp,
1234
1234
  onClick?.();
1235
1235
  return;
1236
1236
  }
1237
+ if (e.altKey && (e.key === "ArrowUp" || e.key === "ArrowDown") && handlers) {
1238
+ e.preventDefault();
1239
+ handlers.onMoveKey(id, e.key === "ArrowUp" ? "up" : "down");
1240
+ return;
1241
+ }
1242
+ if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "d" && handlers) {
1243
+ e.preventDefault();
1244
+ handlers.onCopyKey(id);
1245
+ return;
1246
+ }
1237
1247
  const to = NAVIGATION_KEYS[e.key];
1238
1248
  if (to && handlers) {
1239
1249
  e.preventDefault();
@@ -3605,7 +3615,7 @@ const createNodeRegistry = () => {
3605
3615
  }
3606
3616
  };
3607
3617
  };
3608
- const useDndKeyboard = ({ sections, selectedId, selectedIndex, selectOnly, move, requestDelete }) => {
3618
+ const useDndKeyboard = ({ sections, selectedId, selectedIndex, selectOnly, move, copy, requestDelete }) => {
3609
3619
  const { announcements: say } = useLiveMessages();
3610
3620
  const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 10 } }), useSensor(KeyboardSensor, {
3611
3621
  coordinateGetter: sortableKeyboardCoordinates,
@@ -3643,6 +3653,23 @@ const useDndKeyboard = ({ sections, selectedId, selectedIndex, selectOnly, move,
3643
3653
  move(id, direction);
3644
3654
  if (to === 0 || to === sections.length - 1) focusSection(id);
3645
3655
  };
3656
+ const focusSelectedRef = useRef(false);
3657
+ const onMoveKey = (id, direction) => {
3658
+ const to = sections.findIndex((section) => section.id === id) + (direction === "up" ? -1 : 1);
3659
+ if (to < 0 || to >= sections.length) return;
3660
+ selectOnly(id);
3661
+ move(id, direction);
3662
+ focusSelectedRef.current = true;
3663
+ };
3664
+ const onCopyKey = (id) => {
3665
+ copy(id);
3666
+ focusSelectedRef.current = true;
3667
+ };
3668
+ useEffect(() => {
3669
+ if (!focusSelectedRef.current || selectedId === null) return;
3670
+ focusSelectedRef.current = false;
3671
+ focusSection(selectedId);
3672
+ });
3646
3673
  useEffect(() => {
3647
3674
  if (selectedId === null) return;
3648
3675
  const frame = requestAnimationFrame(() => {
@@ -3661,6 +3688,8 @@ const useDndKeyboard = ({ sections, selectedId, selectedIndex, selectOnly, move,
3661
3688
  sectionNodes,
3662
3689
  onNavigate,
3663
3690
  onDeleteKey,
3691
+ onMoveKey,
3692
+ onCopyKey,
3664
3693
  onMoveButton
3665
3694
  };
3666
3695
  };
@@ -4017,12 +4046,13 @@ const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange:
4017
4046
  onBeforeDelete
4018
4047
  });
4019
4048
  const onDelete = (id) => requestDelete(id);
4020
- const { sensors, announcements, screenReaderInstructions, sectionNodes, onNavigate, onDeleteKey, onMoveButton } = useDndKeyboard({
4049
+ const { sensors, announcements, screenReaderInstructions, sectionNodes, onNavigate, onDeleteKey, onMoveKey, onCopyKey, onMoveButton } = useDndKeyboard({
4021
4050
  sections,
4022
4051
  selectedId,
4023
4052
  selectedIndex,
4024
4053
  selectOnly,
4025
4054
  move: moveSection,
4055
+ copy: onCopy,
4026
4056
  requestDelete
4027
4057
  });
4028
4058
  const { inspector, inspecting, onInspectMove, onInspectPick, onInspectLeave, highlightRect } = useInspectorState({
@@ -4082,7 +4112,9 @@ const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange:
4082
4112
  onInspectLeave,
4083
4113
  nodeRef: sectionNodes.register,
4084
4114
  onNavigate,
4085
- onDeleteKey
4115
+ onDeleteKey,
4116
+ onMoveKey,
4117
+ onCopyKey
4086
4118
  };
4087
4119
  const canvas = /* @__PURE__ */ jsxs(SectionHandlersContext.Provider, {
4088
4120
  value: sectionHandlers,
@@ -4194,4 +4226,4 @@ Dnd.Layout = Layout;
4194
4226
  //#endregion
4195
4227
  export { Panel as a, useDndChildren as c, useDndLayout as d, useDndPalette as f, DraggableItem as h, Palette as i, resolvePanelBindings as l, useDndInspector as m, Canvas as n, Field as o, useDndPanel as p, Layout as r, useDndItems as s, Dnd as t, withPanelCommit as u };
4196
4228
 
4197
- //# sourceMappingURL=dnd-BvjEDo-x.js.map
4229
+ //# sourceMappingURL=dnd-COjjjuD7.js.map