@wordpress/media-editor 0.14.0 → 0.16.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/CHANGELOG.md +5 -0
- package/build/components/media-editor/index.cjs +54 -44
- package/build/components/media-editor/index.cjs.map +2 -2
- package/build/components/media-editor/use-crop-options.cjs.map +2 -2
- package/build/components/media-editor/use-save-media-editor.cjs.map +2 -2
- package/build/components/media-editor-canvas/index.cjs.map +2 -2
- package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
- package/build/components/media-editor-fine-rotation/index.cjs.map +2 -2
- package/build/components/media-editor-image-controls/index.cjs.map +2 -2
- package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +2 -2
- package/build/components/media-editor-modal/build-modifiers.cjs.map +2 -2
- package/build/components/media-editor-modal/index.cjs.map +2 -2
- package/build/components/media-editor-provider/index.cjs.map +2 -2
- package/build/components/media-form/index.cjs.map +2 -2
- package/build/components/media-preview/index.cjs.map +2 -2
- package/build/components/rotation-ruler/index.cjs.map +2 -2
- package/build/components/rotation-ruler/use-ruler-drag.cjs.map +2 -2
- package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
- package/build/image-editor/core/camera.cjs.map +2 -2
- package/build/image-editor/core/constants.cjs.map +2 -2
- package/build/image-editor/core/containment.cjs.map +2 -2
- package/build/image-editor/core/crop-rect.cjs.map +2 -2
- package/build/image-editor/core/export/canvas-renderer.cjs.map +2 -2
- package/build/image-editor/core/interaction-controller.cjs.map +2 -2
- package/build/image-editor/core/math/sanitize.cjs.map +2 -2
- package/build/image-editor/core/setter-helpers.cjs.map +2 -2
- package/build/image-editor/core/source-region.cjs.map +2 -2
- package/build/image-editor/core/state.cjs.map +2 -2
- package/build/image-editor/core/stencil-math.cjs.map +2 -2
- package/build/image-editor/core/transform-style.cjs.map +2 -2
- package/build/image-editor/core/transforms/pipeline.cjs.map +2 -2
- package/build/image-editor/core/viewport-state.cjs.map +2 -2
- package/build/image-editor/react/components/cropper-provider.cjs.map +2 -2
- package/build/image-editor/react/components/cropper.cjs.map +2 -2
- package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +2 -2
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +2 -2
- package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +2 -2
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
- package/build/image-editor/react/components/viewport-provider.cjs.map +2 -2
- package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-transform-style.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-viewport-state.cjs.map +2 -2
- package/build/lock-unlock.cjs.map +2 -2
- package/build/private-apis.cjs.map +2 -2
- package/build/state/composite-reducer.cjs.map +2 -2
- package/build/state/media-editor-state-provider.cjs.map +2 -2
- package/build/state/types.cjs.map +2 -2
- package/build/state/use-media-editor-state.cjs.map +2 -2
- package/build/store/index.cjs.map +2 -2
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/media-editor/index.mjs +54 -45
- package/build-module/components/media-editor/index.mjs.map +2 -2
- package/build-module/components/media-editor/use-crop-options.mjs.map +2 -2
- package/build-module/components/media-editor/use-save-media-editor.mjs.map +2 -2
- package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
- package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
- package/build-module/components/media-editor-fine-rotation/index.mjs.map +2 -2
- package/build-module/components/media-editor-image-controls/index.mjs.map +2 -2
- package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +2 -2
- package/build-module/components/media-editor-modal/build-modifiers.mjs.map +2 -2
- package/build-module/components/media-editor-modal/index.mjs.map +2 -2
- package/build-module/components/media-editor-provider/index.mjs.map +2 -2
- package/build-module/components/media-form/index.mjs.map +2 -2
- package/build-module/components/media-preview/index.mjs.map +2 -2
- package/build-module/components/rotation-ruler/index.mjs.map +2 -2
- package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +2 -2
- package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
- package/build-module/image-editor/core/camera.mjs.map +2 -2
- package/build-module/image-editor/core/constants.mjs.map +2 -2
- package/build-module/image-editor/core/containment.mjs.map +2 -2
- package/build-module/image-editor/core/crop-rect.mjs.map +2 -2
- package/build-module/image-editor/core/export/canvas-renderer.mjs.map +2 -2
- package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
- package/build-module/image-editor/core/math/sanitize.mjs.map +2 -2
- package/build-module/image-editor/core/setter-helpers.mjs.map +2 -2
- package/build-module/image-editor/core/source-region.mjs.map +2 -2
- package/build-module/image-editor/core/state.mjs.map +2 -2
- package/build-module/image-editor/core/stencil-math.mjs.map +2 -2
- package/build-module/image-editor/core/transform-style.mjs.map +2 -2
- package/build-module/image-editor/core/transforms/pipeline.mjs.map +2 -2
- package/build-module/image-editor/core/viewport-state.mjs.map +2 -2
- package/build-module/image-editor/react/components/cropper-provider.mjs.map +2 -2
- package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
- package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +2 -2
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +2 -2
- package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +2 -2
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
- package/build-module/image-editor/react/components/viewport-provider.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +2 -2
- package/build-module/lock-unlock.mjs.map +2 -2
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/state/composite-reducer.mjs.map +2 -2
- package/build-module/state/media-editor-state-provider.mjs.map +2 -2
- package/build-module/state/types.mjs.map +2 -2
- package/build-module/state/use-media-editor-state.mjs.map +2 -2
- package/build-module/store/index.mjs.map +2 -2
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/style-rtl.css +2 -2
- package/build-style/style.css +2 -2
- package/build-types/components/media-editor/index.d.ts.map +1 -1
- package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
- package/build-types/components/media-editor/use-save-media-editor.d.ts +0 -3
- package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
- package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
- package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
- package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
- package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
- package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
- package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -3
- package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +1 -1
- package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
- package/build-types/components/media-editor-provider/index.d.ts.map +1 -1
- package/build-types/components/media-form/index.d.ts.map +1 -1
- package/build-types/components/media-preview/index.d.ts.map +1 -1
- package/build-types/components/rotation-ruler/index.d.ts.map +1 -1
- package/build-types/components/rotation-ruler/stories/index.story.d.ts +0 -6
- package/build-types/components/rotation-ruler/stories/index.story.d.ts.map +1 -1
- package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
- package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
- package/build-types/image-editor/core/camera.d.ts +0 -3
- package/build-types/image-editor/core/camera.d.ts.map +1 -1
- package/build-types/image-editor/core/constants.d.ts +0 -3
- package/build-types/image-editor/core/constants.d.ts.map +1 -1
- package/build-types/image-editor/core/containment.d.ts +0 -3
- package/build-types/image-editor/core/containment.d.ts.map +1 -1
- package/build-types/image-editor/core/crop-rect.d.ts +0 -3
- package/build-types/image-editor/core/crop-rect.d.ts.map +1 -1
- package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -3
- package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +1 -1
- package/build-types/image-editor/core/interaction-controller.d.ts +0 -3
- package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
- package/build-types/image-editor/core/math/sanitize.d.ts +0 -3
- package/build-types/image-editor/core/math/sanitize.d.ts.map +1 -1
- package/build-types/image-editor/core/setter-helpers.d.ts +0 -3
- package/build-types/image-editor/core/setter-helpers.d.ts.map +1 -1
- package/build-types/image-editor/core/source-region.d.ts +0 -3
- package/build-types/image-editor/core/source-region.d.ts.map +1 -1
- package/build-types/image-editor/core/state.d.ts +0 -3
- package/build-types/image-editor/core/state.d.ts.map +1 -1
- package/build-types/image-editor/core/stencil-math.d.ts.map +1 -1
- package/build-types/image-editor/core/transform-style.d.ts +0 -3
- package/build-types/image-editor/core/transform-style.d.ts.map +1 -1
- package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -3
- package/build-types/image-editor/core/transforms/pipeline.d.ts.map +1 -1
- package/build-types/image-editor/core/viewport-state.d.ts +0 -3
- package/build-types/image-editor/core/viewport-state.d.ts.map +1 -1
- package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -3
- package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
- package/build-types/image-editor/react/components/cropper.d.ts +0 -6
- package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
- package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -3
- package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +1 -1
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -3
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +1 -1
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -3
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +1 -1
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -3
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
- package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -3
- package/build-types/image-editor/react/components/viewport-provider.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -3
- package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -3
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +0 -3
- package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -3
- package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -3
- package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -3
- package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +1 -1
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts +0 -6
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/state/composite-reducer.d.ts +0 -3
- package/build-types/state/composite-reducer.d.ts.map +1 -1
- package/build-types/state/media-editor-state-provider.d.ts +0 -3
- package/build-types/state/media-editor-state-provider.d.ts.map +1 -1
- package/build-types/state/types.d.ts +0 -3
- package/build-types/state/types.d.ts.map +1 -1
- package/build-types/state/use-media-editor-state.d.ts +0 -3
- package/build-types/state/use-media-editor-state.d.ts.map +1 -1
- package/build-types/store/index.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +0 -3
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +0 -3
- package/build-types/store/selectors.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/components/media-editor/index.tsx +83 -78
- package/src/components/media-editor/test/use-crop-options.tsx +0 -7
- package/src/components/media-editor/use-crop-options.ts +0 -7
- package/src/components/media-editor/use-save-media-editor.ts +0 -7
- package/src/components/media-editor-canvas/index.tsx +0 -11
- package/src/components/media-editor-crop-panel/index.tsx +0 -7
- package/src/components/media-editor-crop-panel/test/index.tsx +0 -7
- package/src/components/media-editor-fine-rotation/index.tsx +0 -7
- package/src/components/media-editor-image-controls/index.tsx +0 -7
- package/src/components/media-editor-image-controls/test/index.tsx +0 -7
- package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +0 -3
- package/src/components/media-editor-modal/build-modifiers.ts +0 -3
- package/src/components/media-editor-modal/index.tsx +0 -7
- package/src/components/media-editor-modal/test/build-modifiers.test.ts +0 -8
- package/src/components/media-editor-modal/test/index.tsx +0 -11
- package/src/components/media-editor-provider/index.tsx +0 -3
- package/src/components/media-form/index.tsx +0 -7
- package/src/components/media-preview/index.tsx +0 -7
- package/src/components/rotation-ruler/index.tsx +0 -11
- package/src/components/rotation-ruler/stories/index.story.tsx +0 -11
- package/src/components/rotation-ruler/test/index.tsx +0 -7
- package/src/components/rotation-ruler/use-ruler-drag.ts +0 -3
- package/src/hooks/use-crop-gesture-handlers.ts +0 -7
- package/src/image-editor/core/camera.ts +0 -7
- package/src/image-editor/core/constants.ts +0 -7
- package/src/image-editor/core/containment.ts +0 -7
- package/src/image-editor/core/crop-rect.ts +0 -3
- package/src/image-editor/core/export/canvas-renderer.ts +0 -3
- package/src/image-editor/core/export/test/canvas-renderer.ts +0 -3
- package/src/image-editor/core/interaction-controller.ts +0 -3
- package/src/image-editor/core/math/sanitize.ts +0 -3
- package/src/image-editor/core/math/test/sanitize.ts +0 -3
- package/src/image-editor/core/setter-helpers.ts +0 -3
- package/src/image-editor/core/source-region.ts +0 -7
- package/src/image-editor/core/state.ts +0 -3
- package/src/image-editor/core/stencil-math.ts +0 -3
- package/src/image-editor/core/test/interaction-controller.ts +0 -3
- package/src/image-editor/core/test/preview-export-parity.ts +0 -1
- package/src/image-editor/core/test/stencil-math.ts +0 -3
- package/src/image-editor/core/transform-style.ts +0 -3
- package/src/image-editor/core/transforms/pipeline.ts +0 -3
- package/src/image-editor/core/transforms/test/pipeline.ts +0 -3
- package/src/image-editor/core/viewport-state.ts +0 -3
- package/src/image-editor/react/components/cropper-provider.tsx +0 -7
- package/src/image-editor/react/components/cropper.tsx +0 -12
- package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -7
- package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -3
- package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -3
- package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -7
- package/src/image-editor/react/components/stencils/test/rectangle-stencil.tsx +0 -7
- package/src/image-editor/react/components/test/cropper.tsx +0 -7
- package/src/image-editor/react/components/viewport-provider.tsx +0 -7
- package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -3
- package/src/image-editor/react/hooks/test/use-aria-announcer.ts +0 -11
- package/src/image-editor/react/hooks/test/use-cropper-reducer.ts +0 -7
- package/src/image-editor/react/hooks/test/use-interaction.ts +0 -7
- package/src/image-editor/react/hooks/test/use-transform-style.ts +0 -7
- package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -7
- package/src/image-editor/react/hooks/use-cropper-reducer.ts +0 -7
- package/src/image-editor/react/hooks/use-interaction.ts +0 -7
- package/src/image-editor/react/hooks/use-transform-style.ts +0 -7
- package/src/image-editor/react/hooks/use-viewport-state.ts +0 -7
- package/src/image-editor/stories/rectangle-crop.story.tsx +0 -11
- package/src/lock-unlock.ts +0 -3
- package/src/private-apis.ts +0 -3
- package/src/state/composite-reducer.ts +0 -3
- package/src/state/media-editor-state-provider.tsx +0 -7
- package/src/state/test/use-media-editor-state.ts +0 -7
- package/src/state/types.ts +0 -3
- package/src/state/use-media-editor-state.ts +0 -7
- package/src/store/index.ts +0 -7
- package/src/store/reducer.ts +0 -3
- package/src/store/selectors.ts +0 -3
- package/src/store/test/reducer.ts +0 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/media-editor-keyboard-shortcuts-modal/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { Modal } from '@wordpress/components';\nimport { Fragment } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tdisplayShortcutList,\n\tshortcutAriaLabel,\n\ttype WPKeycodeModifier,\n} from '@wordpress/keycodes';\n\ninterface KeyCombination {\n\t/** Modifier for cross-platform display (e.g. 'primary', 'primaryShift', 'shift'). */\n\tmodifier?: WPKeycodeModifier;\n\t/** The key character(s) to display. Pass an array to render each as its own key. */\n\tcharacter: string | string[];\n\t/** Optional aria-label override (used when character is a symbol). */\n\tariaLabel?: string;\n}\n\ninterface ShortcutEntry {\n\tdescription: string;\n\tkeyCombination: KeyCombination;\n}\n\nconst SHORTCUTS: ShortcutEntry[] = [\n\t{\n\t\tdescription: __( 'Undo' ),\n\t\tkeyCombination: { modifier: 'primary', character: 'z' },\n\t},\n\t{\n\t\tdescription: __( 'Redo' ),\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'z' },\n\t},\n\t{\n\t\tdescription: __( 'Pan' ),\n\t\tkeyCombination: {\n\t\t\tcharacter: [ '↑', '↓', '←', '→' ],\n\t\t\tariaLabel: __( 'Arrow keys' ),\n\t\t},\n\t},\n\t{\n\t\tdescription: __( 'Zoom in' ),\n\t\tkeyCombination: { character: '+' },\n\t},\n\t{\n\t\tdescription: __( 'Zoom out' ),\n\t\tkeyCombination: { character: '-' },\n\t},\n\t{\n\t\tdescription: __( 'Rotate 90° clockwise' ),\n\t\tkeyCombination: { character: 'R' },\n\t},\n\t{\n\t\tdescription: __( 'Rotate 90° counter-clockwise' ),\n\t\tkeyCombination: { modifier: 'shift', character: 'R' },\n\t},\n\t{\n\t\tdescription: __( 'Flip horizontal' ),\n\t\tkeyCombination: { character: 'H' },\n\t},\n\t{\n\t\tdescription: __( 'Flip vertical' ),\n\t\tkeyCombination: { character: 'V' },\n\t},\n\t{\n\t\tdescription: __( 'Pan or resize crop (large step)' ),\n\t\tkeyCombination: {\n\t\t\tmodifier: 'shift',\n\t\t\tcharacter: [ '↑', '↓', '←', '→' ],\n\t\t\tariaLabel: __( 'Shift + Arrow keys' ),\n\t\t},\n\t},\n];\n\nfunction KeyCombinationDisplay( {\n\tkeyCombination,\n}: {\n\tkeyCombination: KeyCombination;\n} ) {\n\tconst { modifier, character, ariaLabel } = keyCombination;\n\n\tlet keys: string[];\n\tif ( Array.isArray( character ) ) {\n\t\tif ( modifier ) {\n\t\t\t// Get the modifier prefix (e.g. ['⇧', '+']) from the first char,\n\t\t\t// then replace the last element with all the individual chars.\n\t\t\tconst sample = displayShortcutList[ modifier ]( character[ 0 ] );\n\t\t\tkeys = [ ...sample.slice( 0, -1 ), ...character ];\n\t\t} else {\n\t\t\tkeys = character;\n\t\t}\n\t} else {\n\t\tkeys = modifier\n\t\t\t? displayShortcutList[ modifier ]( character )\n\t\t\t: [ character ];\n\t}\n\n\tconst charString = Array.isArray( character )\n\t\t? character.join( '' )\n\t\t: character;\n\tlet label: string;\n\tif ( ariaLabel ) {\n\t\tlabel = ariaLabel;\n\t} else if ( modifier ) {\n\t\tlabel = shortcutAriaLabel[ modifier ]( charString );\n\t} else {\n\t\tlabel = charString;\n\t}\n\n\treturn (\n\t\t<kbd\n\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut-term\"\n\t\t\taria-label={ label }\n\t\t>\n\t\t\t{ keys.map( ( key, index ) =>\n\t\t\t\tkey === '+' && modifier ? (\n\t\t\t\t\t<Fragment key={ index }>{ key }</Fragment>\n\t\t\t\t) : (\n\t\t\t\t\t<kbd\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut-key\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ key }\n\t\t\t\t\t</kbd>\n\t\t\t\t)\n\t\t\t) }\n\t\t</kbd>\n\t);\n}\n\ninterface MediaEditorKeyboardShortcutsModalProps {\n\tonClose: () => void;\n}\n\nexport default function MediaEditorKeyboardShortcutsModal( {\n\tonClose,\n}: MediaEditorKeyboardShortcutsModalProps ) {\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal\"\n\t\t\ttitle={ __( 'Keyboard shortcuts' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<p className=\"media-editor-keyboard-shortcuts-modal__note\">\n\t\t\t\t{ __(\n\t\t\t\t\t'These shortcuts work when the image editor has focus.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t{ /*\n\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t */ }\n\t\t\t{ /* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t<ul\n\t\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut-list\"\n\t\t\t\trole=\"list\"\n\t\t\t>\n\t\t\t\t{ SHORTCUTS.map( ( { description, keyCombination }, index ) => (\n\t\t\t\t\t<li\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className=\"media-editor-keyboard-shortcuts-modal__shortcut-description\">\n\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<KeyCombinationDisplay\n\t\t\t\t\t\t\tkeyCombination={ keyCombination }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t\t{ /* eslint-enable jsx-a11y/no-redundant-roles */ }\n\t\t</Modal>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAsB;AACtB,qBAAyB;AACzB,kBAAmB;AACnB,sBAIO;AA4GF;AA5FL,IAAM,YAA6B;AAAA,EAClC;AAAA,IACC,iBAAa,gBAAI,MAAO;AAAA,IACxB,gBAAgB,EAAE,UAAU,WAAW,WAAW,IAAI;AAAA,EACvD;AAAA,EACA;AAAA,IACC,iBAAa,gBAAI,MAAO;AAAA,IACxB,gBAAgB,EAAE,UAAU,gBAAgB,WAAW,IAAI;AAAA,EAC5D;AAAA,EACA;AAAA,IACC,iBAAa,gBAAI,KAAM;AAAA,IACvB,gBAAgB;AAAA,MACf,WAAW,CAAE,KAAK,KAAK,KAAK,GAAI;AAAA,MAChC,eAAW,gBAAI,YAAa;AAAA,IAC7B;AAAA,EACD;AAAA,EACA;AAAA,IACC,iBAAa,gBAAI,SAAU;AAAA,IAC3B,gBAAgB,EAAE,WAAW,IAAI;AAAA,EAClC;AAAA,EACA;AAAA,IACC,iBAAa,gBAAI,UAAW;AAAA,IAC5B,gBAAgB,EAAE,WAAW,IAAI;AAAA,EAClC;AAAA,EACA;AAAA,IACC,iBAAa,gBAAI,sBAAuB;AAAA,IACxC,gBAAgB,EAAE,WAAW,IAAI;AAAA,EAClC;AAAA,EACA;AAAA,IACC,iBAAa,gBAAI,8BAA+B;AAAA,IAChD,gBAAgB,EAAE,UAAU,SAAS,WAAW,IAAI;AAAA,EACrD;AAAA,EACA;AAAA,IACC,iBAAa,gBAAI,iBAAkB;AAAA,IACnC,gBAAgB,EAAE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EAC1D;AACD,GAA4C;AAC3C,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,WAAQ,gBAAI,oBAAqB;AAAA,MACjC,gBAAiB;AAAA,MAEjB;AAAA,oDAAC,OAAE,WAAU,+CACV;AAAA,UACD;AAAA,QACD,GACD;AAAA,QAMA;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,MAAK;AAAA,YAEH,oBAAU,IAAK,CAAE,EAAE,aAAa,eAAe,GAAG,UACnD;AAAA,cAAC;AAAA;AAAA,gBAEA,WAAU;AAAA,gBAEV;AAAA,8DAAC,UAAK,WAAU,+DACb,uBACH;AAAA,kBACA;AAAA,oBAAC;AAAA;AAAA,sBACA;AAAA;AAAA,kBACD;AAAA;AAAA;AAAA,cARM;AAAA,YASP,CACC;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EAED;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/media-editor-modal/build-modifiers.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import type { CropperState, Size } from '../../image-editor';\nimport { getRotatedBBox } from '../../image-editor/core/camera';\n\n/**\n * A single modifier in the Core REST `/edit` payload. Order is\n * significant — the server applies modifiers sequentially (see\n * `WP_REST_Attachments_Controller::edit_media_item`).\n *\n * Shape/units:\n * - `flip`: booleans per axis. Applied first in this module's output.\n * - `rotate`: `angle` in degrees, clockwise-positive (matches the\n * cropper's own convention; Core negates it internally for\n * `WP_Image_Editor::rotate`, which is counterclockwise-positive).\n * - `crop`: percentages (0–100) of the image's dimensions **at the\n * moment the crop is applied**. Because modifiers are applied in\n * order, after a preceding `rotate` the server's\n * `WP_Image_Editor::get_size()` reports the full post-rotate AABB,\n * so the percentages are of that AABB. Origin is top-left.\n */\nexport type Modifier =\n\t| {\n\t\t\ttype: 'flip';\n\t\t\targs: { flip: { horizontal: boolean; vertical: boolean } };\n\t }\n\t| { type: 'rotate'; args: { angle: number } }\n\t| {\n\t\t\ttype: 'crop';\n\t\t\targs: { left: number; top: number; width: number; height: number };\n\t };\n\n/**\n * Tolerance (percent) used to decide whether a crop rect is effectively\n * full-frame. Sub-pixel / float-ulp deltas below this value are treated\n * as no crop. Matches the historical threshold used by the legacy\n * `use-save-image.js` (which compared against `99.9`).\n */\nconst CROP_TOLERANCE = 0.1;\n\n/**\n * Build a Core-compatible modifiers array from the cropper state.\n *\n * Emits `[flip, rotate, crop]` in that order. Identity operations are\n * pruned — an absent flip, a rotation that normalizes to 0°, and a crop\n * rect that covers (within tolerance) the full post-rotate AABB each\n * produce no modifier. An identity state (fresh image, no edits) returns\n * an empty array; callers can use that to skip the `/edit` call.\n *\n * Frames and math:\n *\n * The cropper's `cropRect` is stored as fractions of the **snap-rotation**\n * bounding box (the stencil-reference frame — see `createCamera` /\n * `createExportCamera`). Pan is in that frame; zoom scales the image\n * beneath a fixed stencil. Two conversions are needed to reach the frame\n * Core's crop modifier applies against:\n *\n * 1. Express the stencil rect in snap-AABB **pixels**:\n * Image screen-normalized top-left with zoom/pan is\n * `(0.5 + pan - zoom/2)`; the stencil's pixel footprint is the\n * inverse of that transform applied to `cropRect`.\n *\n * 2. Translate from snap-AABB coords to full-AABB coords. Both AABBs\n * share the source-image center, so the conversion is a pure\n * translation by `(fullCenter - snapCenter)`. Finally, express the\n * translated rect as percentages of the full AABB.\n *\n * Rotation sign: the cropper composes `flip · R(θ)` on the source (see\n * `createExportCamera` — rotate then flip). Core's `[flip, rotate]`\n * applies the opposite order: `R(θ') · flip`. For both to land on the\n * same pixels we invert the rotation sign when exactly one flip axis\n * is set (`flip_h · R(θ) = R(-θ) · flip_h`). Both-or-neither flips\n * leave the sign alone because `flip_h · flip_v = -I` commutes with\n * rotation.\n *\n * @param state Current cropper state.\n * @param imageSize Natural dimensions of the source image.\n * @return Ordered modifier array; empty when nothing is server-relevant.\n */\nexport function buildModifiers(\n\tstate: CropperState,\n\timageSize: Size\n): Modifier[] {\n\tconst modifiers: Modifier[] = [];\n\n\tif ( imageSize.width === 0 || imageSize.height === 0 ) {\n\t\treturn modifiers;\n\t}\n\n\tconst { cropRect, pan, zoom, flip } = state;\n\tconst hasFlipH = flip.horizontal;\n\tconst hasFlipV = flip.vertical;\n\n\tif ( hasFlipH || hasFlipV ) {\n\t\tmodifiers.push( {\n\t\t\ttype: 'flip',\n\t\t\targs: { flip: { horizontal: hasFlipH, vertical: hasFlipV } },\n\t\t} );\n\t}\n\n\tconst rawAngle = ( ( state.rotation % 360 ) + 360 ) % 360;\n\t// Invert the sign for single-axis flips so Core's `flip → rotate`\n\t// pipeline matches the cropper's `rotate → flip` composition.\n\tconst singleAxisFlip = hasFlipH !== hasFlipV;\n\tconst signedAngle = singleAxisFlip ? ( 360 - rawAngle ) % 360 : rawAngle;\n\tif ( signedAngle !== 0 ) {\n\t\tmodifiers.push( { type: 'rotate', args: { angle: signedAngle } } );\n\t}\n\n\tconst snapRotation = Math.round( state.rotation / 90 ) * 90;\n\tconst { width: snapW, height: snapH } = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tsnapRotation\n\t);\n\tconst { width: fullW, height: fullH } = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tstate.rotation\n\t);\n\n\t// Stencil rect in snap-AABB pixels. Inverts `createExportCamera`'s\n\t// pan/zoom composition to recover the pixel rectangle the stencil\n\t// framed in that frame.\n\tconst imgLeft = 0.5 + pan.x - zoom / 2;\n\tconst imgTop = 0.5 + pan.y - zoom / 2;\n\tconst snapX = ( ( cropRect.x - imgLeft ) / zoom ) * snapW;\n\tconst snapY = ( ( cropRect.y - imgTop ) / zoom ) * snapH;\n\tconst widthPx = ( cropRect.width / zoom ) * snapW;\n\tconst heightPx = ( cropRect.height / zoom ) * snapH;\n\n\t// Translate to the full AABB (both centered on source).\n\tconst offsetX = ( fullW - snapW ) / 2;\n\tconst offsetY = ( fullH - snapH ) / 2;\n\tconst fullX = snapX + offsetX;\n\tconst fullY = snapY + offsetY;\n\n\t// Percentages of the full AABB — Core's crop frame after rotate.\n\tconst leftPct = ( fullX / fullW ) * 100;\n\tconst topPct = ( fullY / fullH ) * 100;\n\tconst widthPct = ( widthPx / fullW ) * 100;\n\tconst heightPct = ( heightPx / fullH ) * 100;\n\n\tconst coversFullFrame =\n\t\tleftPct <= CROP_TOLERANCE &&\n\t\ttopPct <= CROP_TOLERANCE &&\n\t\twidthPct >= 100 - CROP_TOLERANCE &&\n\t\theightPct >= 100 - CROP_TOLERANCE;\n\n\tif ( ! coversFullFrame ) {\n\t\tmodifiers.push( {\n\t\t\ttype: 'crop',\n\t\t\targs: {\n\t\t\t\tleft: leftPct,\n\t\t\t\ttop: topPct,\n\t\t\t\twidth: widthPct,\n\t\t\t\theight: heightPct,\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn modifiers;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA+B;AAmC/B,IAAM,iBAAiB;AAyChB,SAAS,eACf,OACA,WACa;AACb,QAAM,YAAwB,CAAC;AAE/B,MAAK,UAAU,UAAU,KAAK,UAAU,WAAW,GAAI;AACtD,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,UAAU,KAAK,MAAM,KAAK,IAAI;AACtC,QAAM,WAAW,KAAK;AACtB,QAAM,WAAW,KAAK;AAEtB,MAAK,YAAY,UAAW;AAC3B,cAAU,KAAM;AAAA,MACf,MAAM;AAAA,MACN,MAAM,EAAE,MAAM,EAAE,YAAY,UAAU,UAAU,SAAS,EAAE;AAAA,IAC5D,CAAE;AAAA,EACH;AAEA,QAAM,YAAe,MAAM,WAAW,MAAQ,OAAQ;AAGtD,QAAM,iBAAiB,aA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@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/media-editor-modal/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { Modal } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Field } from '@wordpress/dataviews';\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\nimport MediaEditor from '../media-editor';\nimport type { Media } from '../media-editor-provider';\nimport { store as mediaEditorStore } from '../../store';\nimport type { MediaEditorModalUpdate } from '../../store/actions';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\ninterface MediaEditorModalProps {\n\t/**\n\t * Attachment fields to render in the Details tab.\n\t *\n\t * Passed from the editor layer (which owns the `usePostFields` hook),\n\t * since `@wordpress/media-editor` cannot depend on `@wordpress/editor`.\n\t */\n\tfields?: Field< Media >[];\n\t/**\n\t * Fixed aspect-ratio presets for image cropping. Free and Original are\n\t * always provided by the media editor.\n\t */\n\taspectRatioPresets?: AspectRatioPreset[];\n}\n\nexport function MediaEditorModal( {\n\tfields = [],\n\taspectRatioPresets,\n}: MediaEditorModalProps ) {\n\tconst { isModalOpen, id, onUpdate, onClose } = useSelect( ( select ) => {\n\t\tconst { isOpen, getId, getOnUpdate, getOnClose } =\n\t\t\tselect( mediaEditorStore );\n\t\treturn {\n\t\t\tisModalOpen: isOpen(),\n\t\t\tid: getId(),\n\t\t\tonUpdate: getOnUpdate(),\n\t\t\tonClose: getOnClose(),\n\t\t};\n\t}, [] );\n\n\tconst { closeMediaEditorModal } = useDispatch( mediaEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tif ( ! isModalOpen || ! id ) {\n\t\treturn null;\n\t}\n\n\tconst portalElement =\n\t\ttypeof document === 'undefined' ? null : document.body;\n\n\t// React synthetic events bubble through the React tree, not the DOM tree,\n\t// so a host `ShortcutProvider` higher up still receives keydown events\n\t// from inside this portaled modal. Stop propagation at the modal boundary\n\t// so host shortcuts (undo/redo, save, etc.) don't fire from within.\n\tconst stopKeyDownPropagation = (\n\t\tevent: ReactKeyboardEvent< HTMLDivElement >\n\t) => {\n\t\tevent.stopPropagation();\n\t};\n\n\tconst handleClose = () => {\n\t\tcloseMediaEditorModal();\n\t\tonClose?.();\n\t};\n\n\treturn (\n\t\t<MediaEditor\n\t\t\tid={ id }\n\t\t\tfields={ fields }\n\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t\tshowCloseButton\n\t\t\tshouldCloseOnEsc\n\t\t\tnoticesClassName=\"media-editor-modal__snackbar\"\n\t\t\tnoticesPortalElement={ portalElement }\n\t\t\tonClose={ handleClose }\n\t\t\tonSaved={ ( { id: savedId, url, previous } ) => {\n\t\t\t\tif ( savedId && onUpdate ) {\n\t\t\t\t\tconst update: MediaEditorModalUpdate = {\n\t\t\t\t\t\tid: savedId,\n\t\t\t\t\t\turl,\n\t\t\t\t\t};\n\t\t\t\t\tonUpdate( update );\n\t\t\t\t}\n\t\t\t\thandleClose();\n\t\t\t\tif ( previous && savedId !== previous.id && onUpdate ) {\n\t\t\t\t\t// Intentionally unscoped: the modal is closing, so the\n\t\t\t\t\t// snackbar surfaces in the host editor (not the media\n\t\t\t\t\t// editor's `MEDIA_EDITOR_NOTICES_CONTEXT` region).\n\t\t\t\t\tcreateSuccessNotice( __( 'Image edited.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\tonUpdate( {\n\t\t\t\t\t\t\t\t\t\tid: previous.id,\n\t\t\t\t\t\t\t\t\t\turl: previous.url,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} }\n\t\t\trenderFrame={ ( {\n\t\t\t\tchildren,\n\t\t\t\theaderActions,\n\t\t\t\tfooterActions,\n\t\t\t\tfooterLayout,\n\t\t\t\tonRequestClose,\n\t\t\t\tonKeyDown,\n\t\t\t\tshouldCloseOnClickOutside,\n\t\t\t} ) => (\n\t\t\t\t<ShortcutProvider\n\t\t\t\t\tclassName=\"media-editor-modal__shortcut-scope\"\n\t\t\t\t\tonKeyDown={ stopKeyDownPropagation }\n\t\t\t\t>\n\t\t\t\t\t<Modal\n\t\t\t\t\t\tclassName=\"media-editor-modal\"\n\t\t\t\t\t\ttitle={ __( 'Edit media' ) }\n\t\t\t\t\t\tsize=\"fill\"\n\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\tshouldCloseOnClickOutside={ shouldCloseOnClickOutside }\n\t\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\t\t\theaderActions={ headerActions }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={ `media-editor-modal__footer is-${ footerLayout }` }\n\t\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\t\taria-label={ __( 'Editor actions' ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ footerActions }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</Modal>\n\t\t\t\t</ShortcutProvider>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default MediaEditorModal;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAsB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GAAG;AAAA,YAC3C,MAAM;AAAA,YACN,SAAS;AAAA,cACR;AAAA,gBACC,WAAO,gBAAI,MAAO;AAAA,gBAClB,SAAS,MAAM;AACd,2BAAU;AAAA,oBACT,IAAI,SAAS;AAAA,oBACb,KAAK,SAAS;AAAA,kBACf,CAAE;AAAA,gBACH;AAAA,cACD;AAAA,YACD;AAAA,UACD,CAAE;AAAA,QACH;AAAA,MACD;AAAA,MACA,aAAc,CAAE;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,MACC;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,WAAY;AAAA,UAEZ;AAAA,YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,WAAQ,gBAAI,YAAa;AAAA,cACzB,MAAK;AAAA,cACL,eAAgB;AAAA,cAChB;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cAEE;AAAA;AAAA,gBACF;AAAA,kBAAC;AAAA;AAAA,oBACA,WAAY,iCAAkC,YAAa;AAAA,oBAC3D,MAAK;AAAA,oBACL,kBAAa,gBAAI,gBAAiB;AAAA,oBAEhC;AAAA;AAAA,gBACH;AAAA;AAAA;AAAA,UACD;AAAA;AAAA,MACD;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,6BAAQ;",
|
|
6
6
|
"names": ["mediaEditorStore", "noticesStore", "MediaEditor"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/media-editor-provider/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { createContext, useContext } from '@wordpress/element';\nimport type { Field } from '@wordpress/dataviews';\nimport type { ReactNode } from 'react';\n\n/**\n * Media object from WordPress REST API.\n */\nexport interface Media {\n\tid?: number;\n\tsource_url?: string;\n\tmime_type?: string;\n\talt_text?: string;\n\ttitle?: string | { rendered?: string; raw?: string };\n\tcaption?: string | { rendered?: string; raw?: string };\n\tdescription?: string | { rendered?: string; raw?: string };\n\t[ key: string ]: any;\n}\n\n/**\n * Context value for MediaEditor.\n */\nexport interface MediaEditorContextValue {\n\tmedia?: Media;\n\tonChange?: ( updates: Partial< Media > ) => void;\n\tfields: Field< Media >[];\n}\n\n/**\n * Props for MediaEditorProvider.\n */\nexport interface MediaEditorProviderProps {\n\t/** The media object to edit. */\n\tvalue?: Media;\n\t/**\n\t * Callback when media is updated.\n\t *\n\t * Optional - if not provided, the MediaEditor can be used in a read-only mode,\n\t * useful for preview-only scenarios.\n\t */\n\tonChange?: ( updates: Partial< Media > ) => void;\n\t/** Configuration settings for the media editor. */\n\tsettings?: {\n\t\tfields?: Field< Media >[];\n\t};\n\t/** Child components. */\n\tchildren: ReactNode;\n}\n\nconst MediaEditorContext = createContext< MediaEditorContextValue | undefined >(\n\tundefined\n);\n\nexport function MediaEditorProvider( {\n\tvalue,\n\tonChange,\n\tsettings = {},\n\tchildren,\n}: MediaEditorProviderProps ) {\n\tconst contextValue: MediaEditorContextValue = {\n\t\tmedia: value,\n\t\tonChange,\n\t\tfields: settings.fields || [],\n\t};\n\n\treturn (\n\t\t<MediaEditorContext.Provider value={ contextValue }>\n\t\t\t{ children }\n\t\t</MediaEditorContext.Provider>\n\t);\n}\n\n/**\n * Hook to access the MediaEditor context.\n *\n * Must be used within a MediaEditorProvider component.\n *\n * @return MediaEditorContextValue value with media, onChange, and fields, etc.\n */\nexport function useMediaEditorContext(): MediaEditorContextValue {\n\tconst context = useContext( MediaEditorContext );\n\tif ( ! context ) {\n\t\tthrow new Error(\n\t\t\t'useMediaEditorContext must be used within MediaEditorProvider'\n\t\t);\n\t}\n\treturn context;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0C;AAiExC;AAjBF,IAAM,yBAAqB;AAAA,EAC1B;AACD;AAEO,SAAS,oBAAqB;AAAA,EACpC;AAAA,EACA;AAAA,EACA,WAAW,CAAC;AAAA,EACZ;AACD,GAA8B;AAC7B,QAAM,eAAwC;AAAA,IAC7C,OAAO;AAAA,IACP;AAAA,IACA,QAAQ,SAAS,UAAU,CAAC;AAAA,EAC7B;AAEA,SACC,4CAAC,mBAAmB,UAAnB,EAA4B,OAAQ,cAClC,UACH;AAEF;AASO,SAAS,wBAAiD;AAChE,QAAM,cAAU,2BAAY,kBAAmB;AAC/C,MAAK,CAAE,SAAU;AAChB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/media-form/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { DataForm } from '@wordpress/dataviews';\nimport type { Form, Field } from '@wordpress/dataviews';\nimport { Spinner, __experimentalVStack as VStack } from '@wordpress/components';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport type { ReactNode } from 'react';\nimport { useMediaEditorContext } from '../media-editor-provider';\nimport type { Media } from '../media-editor-provider';\n\n/**\n * Props for MediaForm component.\n */\nexport interface MediaFormProps {\n\tform?: Form;\n\theader?: ReactNode;\n}\n\n/**\n * MediaForm component for editing media metadata.\n *\n * Renders a DataForm with fields for editing media properties like\n * title, alt text, caption, description, etc.\n *\n * @param props - Component props.\n * @param props.form - Optional form configuration.\n * @param props.header - Optional header content to display above the form.\n * @return The MediaForm component.\n */\nexport default function MediaForm( {\n\tform: formOverrides,\n\theader,\n}: MediaFormProps ) {\n\tconst { media, fields, onChange } = useMediaEditorContext();\n\n\tif ( ! media || ! onChange ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-form media-editor-form--loading\">\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Fields that use a regular (non-panel) layout, rendered at the top.\n\tconst regularFieldIds = [ 'title', 'alt_text', 'caption', 'description' ];\n\n\t// Place the non-panel (regular layout) fields at the top of the array,\n\t// with the remaining panel fields below.\n\tconst sortedFields = [\n\t\t...fields.filter( ( field: Field< Media > ) =>\n\t\t\tregularFieldIds.includes( field.id )\n\t\t),\n\t\t...fields.filter(\n\t\t\t( field: Field< Media > ) => ! regularFieldIds.includes( field.id )\n\t\t),\n\t];\n\n\t// Default form structure with panel layout\n\tconst defaultForm: Form = {\n\t\tlayout: {\n\t\t\ttype: 'panel',\n\t\t},\n\t\tfields: sortedFields.map( ( field: Field< Media > ) => {\n\t\t\t// Use regular layout for main editable fields\n\t\t\tif ( regularFieldIds.includes( field.id ) ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: field.id,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\ttype: 'regular',\n\t\t\t\t\t\tlabelPosition: 'top',\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn field.id;\n\t\t} ),\n\t};\n\n\tconst form = formOverrides || defaultForm;\n\n\treturn (\n\t\t<div className=\"media-editor-form\">\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t\t{ __( 'Media details' ) }\n\t\t\t\t</VisuallyHidden>\n\t\t\t\t{ header }\n\t\t\t\t<DataForm\n\t\t\t\t\tdata={ media }\n\t\t\t\t\tfields={ fields }\n\t\t\t\t\tform={ form }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;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|
6
6
|
"names": ["VStack"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/media-preview/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { Spinner } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useMediaEditorContext } from '../media-editor-provider';\nimport { getMediaTypeFromMimeType } from '../../utils';\n\n/**\n * Props for MediaPreview component.\n */\nexport interface MediaPreviewProps {\n\t[ key: string ]: any; // TODO: Define specific props as needed, this will likely be for click handlers, accessibility attributes, etc.\n}\n\n/**\n * Props for MediaPreviewContent component.\n */\ninterface MediaPreviewContentProps {\n\tmediaType: { type: string };\n\tmediaUrl: string;\n\taltText?: string;\n\tdisplayTitle?: string;\n\tmimeType?: string;\n\tonLoad: () => void;\n\tonError: () => void;\n\tloadingState: 'loading' | 'loaded' | 'error';\n}\n\nfunction MediaPreviewContent( {\n\tmediaType,\n\tmediaUrl,\n\taltText,\n\tdisplayTitle,\n\tmimeType,\n\tonLoad,\n\tonError,\n\tloadingState,\n}: MediaPreviewContentProps ) {\n\tswitch ( mediaType.type ) {\n\t\tcase 'image':\n\t\t\treturn (\n\t\t\t\t<img\n\t\t\t\t\tclassName={ loadingState === 'loaded' ? 'loaded' : '' }\n\t\t\t\t\tsrc={ mediaUrl }\n\t\t\t\t\talt={ altText || '' }\n\t\t\t\t\tonLoad={ onLoad }\n\t\t\t\t\tonError={ onError }\n\t\t\t\t/>\n\t\t\t);\n\t\tcase 'video':\n\t\t\treturn (\n\t\t\t\t<video src={ mediaUrl } controls onError={ onError }>\n\t\t\t\t\t{ displayTitle }\n\t\t\t\t</video>\n\t\t\t);\n\t\tcase 'audio':\n\t\t\treturn (\n\t\t\t\t<audio src={ mediaUrl } controls onError={ onError }>\n\t\t\t\t\t{ displayTitle }\n\t\t\t\t</audio>\n\t\t\t);\n\t\tdefault:\n\t\t\treturn (\n\t\t\t\t<div className=\"media-editor-preview__file-info\">\n\t\t\t\t\t<p className=\"media-editor-preview__file-name\">\n\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t</p>\n\t\t\t\t\t<p className=\"media-editor-preview__mime-type\">\n\t\t\t\t\t\t{ mimeType }\n\t\t\t\t\t</p>\n\t\t\t\t\t{ /* eslint-disable-next-line react/jsx-no-target-blank */ }\n\t\t\t\t\t<a\n\t\t\t\t\t\thref={ mediaUrl }\n\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\trel=\"noopener\"\n\t\t\t\t\t\tclassName=\"media-editor-preview__download-link\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'View file' ) }\n\t\t\t\t\t</a>\n\t\t\t\t</div>\n\t\t\t);\n\t}\n}\n\n/**\n * MediaPreview component displays the media file in the editor canvas.\n * Supports images, videos, audio files, and generic file displays.\n *\n * @param props - Component props including click handlers and accessibility attributes.\n * @return The MediaPreview component.\n */\nexport default function MediaPreview( props: MediaPreviewProps ) {\n\tconst [ loadingState, setLoadingState ] = useState<\n\t\t'loading' | 'loaded' | 'error'\n\t>( 'loading' );\n\tconst { media } = useMediaEditorContext();\n\n\tconst {\n\t\tsource_url: mediaUrl,\n\t\tmime_type: mimeType,\n\t\talt_text: altText,\n\t\ttitle,\n\t} = media || {};\n\n\tconst mediaType = getMediaTypeFromMimeType( mimeType );\n\n\tif ( ! mediaUrl ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-preview media-editor-preview--empty\">\n\t\t\t\t<p>{ __( 'No media file available.' ) }</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( loadingState === 'error' ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-preview media-editor-preview--error\">\n\t\t\t\t<p>{ __( 'Failed to load media file.' ) }</p>\n\t\t\t\t<p className=\"media-editor-preview__url\">{ mediaUrl }</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst displayTitle =\n\t\ttypeof title === 'string' ? title : title?.rendered || title?.raw;\n\n\treturn (\n\t\t<div\n\t\t\t{ ...props }\n\t\t\tclassName={ `media-editor-preview media-editor-preview--${ mediaType.type }` }\n\t\t>\n\t\t\t{ mediaType.type === 'image' && loadingState === 'loading' && (\n\t\t\t\t<div className=\"media-editor-preview__spinner\">\n\t\t\t\t\t<Spinner />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<MediaPreviewContent\n\t\t\t\tmediaType={ mediaType }\n\t\t\t\tmediaUrl={ mediaUrl }\n\t\t\t\taltText={ altText }\n\t\t\t\tdisplayTitle={ displayTitle }\n\t\t\t\tmimeType={ mimeType }\n\t\t\t\tonLoad={ () => setLoadingState( 'loaded' ) }\n\t\t\t\tonError={ () => setLoadingState( 'error' ) }\n\t\t\t\tloadingState={ loadingState }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAwB;AACxB,qBAAyB;AACzB,kBAAmB;AACnB,mCAAsC;AACtC,mBAAyC;AAoCrC;AAbJ,SAAS,oBAAqB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA8B;AAC7B,UAAS,UAAU,MAAO;AAAA,IACzB,KAAK;AACJ,aACC;AAAA,QAAC;AAAA;AAAA,UACA,WAAY,iBAAiB,WAAW,WAAW;AAAA,UACnD,KAAM;AAAA,UACN,KAAM,WAAW;AAAA,UACjB;AAAA,UACA;AAAA;AAAA,MACD;AAAA,IAEF,KAAK;AACJ,aACC,4CAAC,WAAM,KAAM,UAAW,UAAQ,MAAC,SAC9B,wBACH;AAAA,IAEF,KAAK;AACJ,aACC,4CAAC,WAAM,KAAM,UAAW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ACzC,SAAU,MAAM,gBAAiB,OAAQ;AAAA,YACzC;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/rotation-ruler/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport type { CSSProperties, KeyboardEvent } from 'react';\nimport { useId, useMemo, useRef } from '@wordpress/element';\nimport { useRulerDrag, clampValue } from './use-ruler-drag';\n\nexport interface RotationRulerProps {\n\t/** Current value. */\n\tvalue: number;\n\t/** Called with the next value on each change. */\n\tonChange: ( value: number ) => void;\n\t/** Lower bound of the range. Default: -45. */\n\tmin?: number;\n\t/** Upper bound of the range. Default: 45. */\n\tmax?: number;\n\t/**\n\t * Value step for drag and keyboard arrows. Default: 1. Drag values\n\t * are quantized to multiples of `step`. Holding Shift during drag\n\t * or with arrow keys halves the step for precision adjustment.\n\t */\n\tstep?: number;\n\t/** Accessible label for the slider input. */\n\tlabel: string;\n\t/**\n\t * Unit suffix shown in the active label and `aria-valuetext`.\n\t * Default: `°`.\n\t */\n\tunit?: string;\n\t/** CSS pixels of pointer travel per `step`. Default: 6. */\n\tpixelsPerStep?: number;\n\t/** Optional extra class for the wrapper. */\n\tclassName?: string;\n\t/**\n\t * Optional id for the underlying input; auto-generated when\n\t * omitted.\n\t */\n\tid?: string;\n\t/** When true, ignores all input. */\n\tdisabled?: boolean;\n}\n\nconst STRIP_HEIGHT = 32;\nconst LABEL_BASELINE_Y = 11;\nconst MAJOR_INTERVAL = 15;\nconst TICK_HEIGHT_MINOR = 4;\nconst TICK_HEIGHT_MID = 8;\nconst TICK_HEIGHT_MAJOR = 14;\n\ntype TickKind = 'minor' | 'mid' | 'major';\ninterface Tick {\n\tvalue: number;\n\tkind: TickKind;\n\theight: number;\n}\n\n/**\n * Build the tick list for the ruler strip.\n *\n * @param min Lower bound of the ruler in value units.\n * @param max Upper bound of the ruler in value units.\n */\nfunction useTicks( min: number, max: number ): Tick[] {\n\treturn useMemo( () => {\n\t\tconst out: Tick[] = [];\n\t\tfor ( let v = Math.ceil( min ); v <= Math.floor( max ); v += 1 ) {\n\t\t\tlet kind: TickKind = 'minor';\n\t\t\tlet height = TICK_HEIGHT_MINOR;\n\t\t\tif ( v % 15 === 0 ) {\n\t\t\t\tkind = 'major';\n\t\t\t\theight = TICK_HEIGHT_MAJOR;\n\t\t\t} else if ( v % 5 === 0 ) {\n\t\t\t\tkind = 'mid';\n\t\t\t\theight = TICK_HEIGHT_MID;\n\t\t\t}\n\t\t\tout.push( { value: v, kind, height } );\n\t\t}\n\t\treturn out;\n\t}, [ min, max ] );\n}\n\n/**\n * Format a numeric ruler value for display, trimming a trailing `.0`.\n *\n * @param value Value to format.\n */\nfunction formatValue( value: number ): string {\n\tconst rounded = Math.round( value * 10 ) / 10;\n\treturn Number.isInteger( rounded )\n\t\t? rounded.toFixed( 0 )\n\t\t: rounded.toFixed( 1 );\n}\n\n/**\n * Horizontal \"scrub-the-ruler\" slider for fine-grained numeric input\n * such as rotation in degrees.\n *\n * Renders a visually hidden `<input type=\"range\">` for assistive\n * technologies and keyboard input alongside a decorative tick strip\n * that the user can drag with a pointer.\n *\n * @param props Component props. See `RotationRulerProps`.\n */\nexport default function RotationRuler( props: RotationRulerProps ) {\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tmin = -45,\n\t\tmax = 45,\n\t\tstep = 1,\n\t\tlabel,\n\t\tunit = '°',\n\t\tpixelsPerStep = 6,\n\t\tclassName,\n\t\tid,\n\t\tdisabled = false,\n\t} = props;\n\tconst inputRef = useRef< HTMLInputElement >( null );\n\tconst generatedId = useId();\n\tconst inputId = id ?? generatedId;\n\n\tconst dragHandlers = useRulerDrag( {\n\t\tvalue,\n\t\tonChange,\n\t\tmin,\n\t\tmax,\n\t\tstep,\n\t\tpixelsPerStep,\n\t\tdisabled,\n\t\tonPointerDownStart: () => inputRef.current?.focus(),\n\t} );\n\n\tconst handleKeyDown = ( event: KeyboardEvent< HTMLInputElement > ) => {\n\t\t// WAI-ARIA slider keyboard pattern: Up/Right increment,\n\t\t// Down/Left decrement. Home / End / PageUp / PageDown fall\n\t\t// through to native input.\n\t\tconst isIncrement =\n\t\t\tevent.key === 'ArrowRight' || event.key === 'ArrowUp';\n\t\tconst isDecrement =\n\t\t\tevent.key === 'ArrowLeft' || event.key === 'ArrowDown';\n\t\tif ( ! isIncrement && ! isDecrement ) {\n\t\t\treturn;\n\t\t}\n\t\t// Always prevent default so the native input's own arrow-key\n\t\t// stepping doesn't double-fire `onChange` after our custom emit.\n\t\tevent.preventDefault();\n\t\tif ( disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tconst direction = isIncrement ? 1 : -1;\n\t\t// Shift halves the step for precision adjustment\n\t\t// (e.g. 0.5° rotation when step is 1°). Same modifier works\n\t\t// on drag — see `useRulerDrag`.\n\t\tconst magnitude = event.shiftKey ? step / 2 : step;\n\t\tconst next = clampValue( value + direction * magnitude, min, max );\n\t\tif ( next !== value ) {\n\t\t\tonChange( next );\n\t\t}\n\t};\n\n\tconst display = `${ formatValue( value ) }${ unit }`;\n\tconst ticks = useTicks( min, max );\n\t// Visual scale is locked to the gesture: 1 step of pointer travel\n\t// (`pixelsPerStep`) maps to `step` value units, so 1 value unit\n\t// renders at `pixelsPerStep / step` CSS pixels. This keeps the\n\t// ticks moving in lock-step with the pointer no matter what the\n\t// caller chooses for `pixelsPerStep` and `step`.\n\tconst pxPerUnit = pixelsPerStep / step;\n\t// `left: 50%` puts the SVG's left edge at the strip's centerline, so\n\t// without an additional `-50%` self-offset all ticks would render to\n\t// the right of the pointer. Combine the centering offset with the\n\t// value-driven offset so value=0 lands the SVG's center on the\n\t// pointer.\n\tconst stripStyle: CSSProperties = useMemo( () => {\n\t\tconst offset = -value * pxPerUnit;\n\t\treturn {\n\t\t\ttransform: `translateX(calc(-50% + ${ offset }px))`,\n\t\t};\n\t}, [ value, pxPerUnit ] );\n\n\t// Closest major (every 15°) to current value. Its normal label is\n\t// suppressed and replaced by the active label, which sits exactly\n\t// under the pointer and shows the precise current value when off-\n\t// major (e.g. \"-7°\") or the major itself when on-major (e.g. \"0°\").\n\tconst closestMajor = Math.round( value / MAJOR_INTERVAL ) * MAJOR_INTERVAL;\n\tconst onMajor = Math.abs( value - closestMajor ) < 0.01;\n\t// Split the number into sign + digits so the sign is rendered in a\n\t// separate span and excluded from the active label's centering, the\n\t// same way the unit is.\n\tconst numberText = onMajor ? `${ closestMajor }` : formatValue( value );\n\tconst isNegative = numberText.startsWith( '-' );\n\tconst digits = isNegative ? numberText.slice( 1 ) : numberText;\n\tconst majorTicks = ticks.filter( ( tick ) => tick.kind === 'major' );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'rotation-ruler', className ) }\n\t\t\trole=\"presentation\"\n\t\t\tdata-disabled={ disabled || undefined }\n\t\t\t{ ...dragHandlers }\n\t\t>\n\t\t\t<input\n\t\t\t\tref={ inputRef }\n\t\t\t\tid={ inputId }\n\t\t\t\ttype=\"range\"\n\t\t\t\tclassName=\"rotation-ruler__input\"\n\t\t\t\tmin={ min }\n\t\t\t\tmax={ max }\n\t\t\t\tstep=\"any\"\n\t\t\t\tvalue={ value }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taria-label={ label }\n\t\t\t\taria-valuetext={ display }\n\t\t\t\tonChange={ ( event ) =>\n\t\t\t\t\tonChange(\n\t\t\t\t\t\tclampValue( event.target.valueAsNumber, min, max )\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tonKeyDown={ handleKeyDown }\n\t\t\t/>\n\t\t\t<div className=\"rotation-ruler__strip\" aria-hidden=\"true\">\n\t\t\t\t<svg\n\t\t\t\t\tclassName=\"rotation-ruler__ticks\"\n\t\t\t\t\tstyle={ stripStyle }\n\t\t\t\t\twidth={ ( max - min ) * pxPerUnit }\n\t\t\t\t\theight={ STRIP_HEIGHT }\n\t\t\t\t\tviewBox={ `${ min * pxPerUnit } 0 ${\n\t\t\t\t\t\t( max - min ) * pxPerUnit\n\t\t\t\t\t} ${ STRIP_HEIGHT }` }\n\t\t\t\t\tpreserveAspectRatio=\"xMidYMid meet\"\n\t\t\t\t>\n\t\t\t\t\t{ ticks.map( ( tick ) => (\n\t\t\t\t\t\t<line\n\t\t\t\t\t\t\tkey={ tick.value }\n\t\t\t\t\t\t\tx1={ tick.value * pxPerUnit }\n\t\t\t\t\t\t\tx2={ tick.value * pxPerUnit }\n\t\t\t\t\t\t\ty1={ STRIP_HEIGHT - tick.height }\n\t\t\t\t\t\t\ty2={ STRIP_HEIGHT }\n\t\t\t\t\t\t\tclassName={ `rotation-ruler__tick rotation-ruler__tick--${ tick.kind }` }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t\t{ majorTicks.map( ( tick ) => (\n\t\t\t\t\t\t<text\n\t\t\t\t\t\t\tkey={ tick.value }\n\t\t\t\t\t\t\tx={ tick.value * pxPerUnit }\n\t\t\t\t\t\t\ty={ LABEL_BASELINE_Y }\n\t\t\t\t\t\t\ttextAnchor=\"middle\"\n\t\t\t\t\t\t\tclassName=\"rotation-ruler__label\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ tick.value }\n\t\t\t\t\t\t\t{ unit }\n\t\t\t\t\t\t</text>\n\t\t\t\t\t) ) }\n\t\t\t\t</svg>\n\t\t\t</div>\n\t\t\t<div className=\"rotation-ruler__active-label\" aria-hidden=\"true\">\n\t\t\t\t<span className=\"rotation-ruler__active-label-number\">\n\t\t\t\t\t{ isNegative && (\n\t\t\t\t\t\t<span className=\"rotation-ruler__active-label-sign\">\n\t\t\t\t\t\t\t-\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ digits }\n\t\t\t\t\t<span className=\"rotation-ruler__active-label-unit\">\n\t\t\t\t\t\t{ unit }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t\t<div className=\"rotation-ruler__pointer\" aria-hidden=\"true\" />\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,qBAAuC;AACvC,4BAAyC;AAoMtC;AA/JH,IAAM,eAAe;AACrB,IAAM,mBAAmB;AACzB,IAAM,iBAAiB;AACvB,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB;AACxB,IAAM,oBAAoB;AAe1B,SAAS,SAAU,KAAa,KAAsB;AACrD,aAAO,wBAAS,MAAM;AACrB,UAAM,MAAc,CAAC;AACrB,aAAU,IAAI,KAAK,KAAM,GAAI,GAAG,KAAK,KAAK,MAAO,GAAI,GAAG,KAAK,GAAI;AAChE,UAAI,OAAiB;AACrB,UAAI,SAAS;AACb,UAAK,IAAI,OAAO,GAAI;AACnB,eAAO;AACP,iBAAS;AAAA,MACV,WAAY,IAAI,MAAM,GAAI;AACzB,eAAO;AACP,iBAAS;AAAA,MACV;AACA,UAAI,KAAM,EAAE,OAAO,GAAG,MAAM,OAAO,CAAE;AAAA,IACtC;AACA,WAAO;AAAA,EACR,GAAG,CAAE,KAAK,GAAI,CAAE;AACjB;AAOA,SAAS,YAAa,OAAwB;AAC7C,QAAM,UAAU,KAAK,MAAO,QAAQ,EAAG,IAAI;AAC3C,SAAO,OAAO,UAAW,OAAQ,IAC9B,QAAQ,QAAS,CAAE,IACnB,QAAQ,QAAS,CAAE;AACvB;AAYe,SAAR,cAAgC,OAA4B;AAClE,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP;AAAA,IACA,OAAO;AAAA,IACP,gBAAgB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yBAAK;AAAA,oBACL;AAAA;AAAA;AAAA,gBAPI,KAAK;AAAA,cAQZ,CACC;AAAA;AAAA;AAAA,QACH,GACD;AAAA,QACA,4CAAC,SAAI,WAAU,gCAA+B,eAAY,QACzD,uDAAC,UAAK,WAAU,uCACb;AAAA,wBACD,4CAAC,UAAK,WAAU,qCAAoC,eAEpD;AAAA,UAEC;AAAA,UACF,4CAAC,UAAK,WAAU,qCACb,gBACH;AAAA,WACD,GACD;AAAA,QACA,4CAAC,SAAI,WAAU,2BAA0B,eAAY,QAAO;AAAA;AAAA;AAAA,EAC7D;AAEF;",
|
|
6
6
|
"names": ["clsx"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/rotation-ruler/use-ruler-drag.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Convert a horizontal pointer delta (px) into a value delta.\n *\n * Negative because dragging the ruler to the right should expose\n * smaller values to the left of the fixed center pointer (and vice\n * versa) — the ruler scrubs *under* the pointer.\n *\n * @param deltaPx Pointer movement in CSS pixels.\n * @param pixelsPerStep CSS pixels of pointer travel per `step`.\n * @param step Value units per step.\n */\nexport function pxToValueDelta(\n\tdeltaPx: number,\n\tpixelsPerStep: number,\n\tstep: number\n): number {\n\treturn ( -deltaPx / pixelsPerStep ) * step;\n}\n\n/**\n * Clamp `value` to the inclusive `[min, max]` interval.\n *\n * @param value Value to clamp.\n * @param min Lower bound (inclusive).\n * @param max Upper bound (inclusive).\n */\nexport function clampValue( value: number, min: number, max: number ): number {\n\tif ( value < min ) {\n\t\treturn min;\n\t}\n\tif ( value > max ) {\n\t\treturn max;\n\t}\n\treturn value;\n}\n\n/**\n * Round `value` to the nearest multiple of `step`.\n *\n * @param value Value to quantize.\n * @param step Step granularity (must be > 0).\n */\nexport function quantize( value: number, step: number ): number {\n\treturn Math.round( value / step ) * step;\n}\n\nexport interface UseRulerDragOptions {\n\tvalue: number;\n\tonChange: ( next: number ) => void;\n\tmin: number;\n\tmax: number;\n\tstep: number;\n\tpixelsPerStep: number;\n\tdisabled: boolean;\n\t/** Called once on pointerdown so the caller can focus the input. */\n\tonPointerDownStart?: () => void;\n}\n\nexport interface RulerDragHandlers {\n\tonPointerDown: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerMove: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerUp: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerCancel: ( event: React.PointerEvent< HTMLElement > ) => void;\n}\n\n/**\n * Drag-the-ruler gesture for a horizontal slider. Translates pointer\n * movement into value changes quantized to `step`; the caller renders\n * the visuals and holds the value.\n *\n * The hook owns no state of its own — every value change is reported\n * through the supplied `onChange`. The \"current value\" is read from a\n * ref so closure staleness during a drag is impossible. Drag continues\n * past the wrapper's bounds (standard slider behaviour); a window-level\n * `pointerup` listener guarantees the drag ends and pointer capture\n * releases even if the underlying captured event never fires on the\n * wrapper.\n *\n * @param options Ruler-drag configuration. See `UseRulerDragOptions`.\n */\nexport function useRulerDrag(\n\toptions: UseRulerDragOptions\n): RulerDragHandlers {\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tmin,\n\t\tmax,\n\t\tstep,\n\t\tpixelsPerStep,\n\t\tdisabled,\n\t\tonPointerDownStart,\n\t} = options;\n\n\t// Mutable mirror of the latest committed value plus per-drag state.\n\t// Pointermove handlers fire far faster than React commits, so we\n\t// cannot read `value` from closure. The `value` write happens in an\n\t// effect (not at render time) to satisfy `react-hooks/refs`; the\n\t// effect flushes after commit, so by the time any pointer handler\n\t// runs, the ref reflects the latest committed `value`.\n\tconst latestRef = useRef< {\n\t\tvalue: number;\n\t\tstartX: number;\n\t\tstartValue: number;\n\t\tactiveStep: number;\n\t\tdragging: boolean;\n\t\tcaptureElement: HTMLElement | null;\n\t\tcapturePointerId: number;\n\t\twindowPointerUp: ( () => void ) | null;\n\t} >( {\n\t\tvalue,\n\t\tstartX: 0,\n\t\tstartValue: 0,\n\t\tactiveStep: step,\n\t\tdragging: false,\n\t\tcaptureElement: null,\n\t\tcapturePointerId: 0,\n\t\twindowPointerUp: null,\n\t} );\n\tuseEffect( () => {\n\t\tlatestRef.current.value = value;\n\t}, [ value ] );\n\n\tconst endDrag = useCallback( () => {\n\t\tconst state = latestRef.current;\n\t\tif ( ! state.dragging ) {\n\t\t\treturn;\n\t\t}\n\t\tstate.dragging = false;\n\t\tif (\n\t\t\tstate.captureElement &&\n\t\t\tstate.captureElement.hasPointerCapture( state.capturePointerId )\n\t\t) {\n\t\t\tstate.captureElement.releasePointerCapture(\n\t\t\t\tstate.capturePointerId\n\t\t\t);\n\t\t}\n\t\tstate.captureElement = null;\n\t\tif ( state.windowPointerUp ) {\n\t\t\twindow.removeEventListener( 'pointerup', state.windowPointerUp );\n\t\t\twindow.removeEventListener(\n\t\t\t\t'pointercancel',\n\t\t\t\tstate.windowPointerUp\n\t\t\t);\n\t\t\tstate.windowPointerUp = null;\n\t\t}\n\t}, [] );\n\n\t// Cleanup any in-flight drag on unmount so we never leak window\n\t// listeners or stale pointer capture.\n\tuseEffect( () => endDrag, [ endDrag ] );\n\n\tconst onPointerDown = useCallback(\n\t\t( event: React.PointerEvent< HTMLElement > ) => {\n\t\t\tif ( disabled || event.button !== 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst state = latestRef.current;\n\t\t\tevent.currentTarget.setPointerCapture( event.pointerId );\n\t\t\tstate.captureElement = event.currentTarget;\n\t\t\tstate.capturePointerId = event.pointerId;\n\t\t\tstate.startX = event.clientX;\n\t\t\tstate.startValue = state.value;\n\t\t\tstate.activeStep = event.shiftKey ? step / 2 : step;\n\t\t\tstate.dragging = true;\n\t\t\tonPointerDownStart?.();\n\n\t\t\t// Window-level backstop. With `setPointerCapture`, the\n\t\t\t// element should always receive `pointerup` even when the\n\t\t\t// cursor is released outside its bounds — but in practice\n\t\t\t// some browsers / window-blur sequences drop the event. The\n\t\t\t// window listener guarantees the drag ends and capture\n\t\t\t// releases.\n\t\t\tconst onWindowUp = () => endDrag();\n\t\t\tstate.windowPointerUp = onWindowUp;\n\t\t\twindow.addEventListener( 'pointerup', onWindowUp );\n\t\t\twindow.addEventListener( 'pointercancel', onWindowUp );\n\t\t},\n\t\t[ disabled, onPointerDownStart, endDrag, step ]\n\t);\n\n\tconst onPointerMove = useCallback(\n\t\t( event: React.PointerEvent< HTMLElement > ) => {\n\t\t\tconst state = latestRef.current;\n\t\t\tif ( ! state.dragging ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Shift toggles fine mode mid-drag. The drag math computes\n\t\t\t// from `startX` / `startValue`, so naively swapping `step`\n\t\t\t// would yank the value backward. Rebase to the current\n\t\t\t// pointer + value so the granularity changes without a\n\t\t\t// jump.\n\t\t\tconst requestedStep = event.shiftKey ? step / 2 : step;\n\t\t\tif ( requestedStep !== state.activeStep ) {\n\t\t\t\tstate.startX = event.clientX;\n\t\t\t\tstate.startValue = state.value;\n\t\t\t\tstate.activeStep = requestedStep;\n\t\t\t}\n\t\t\tconst deltaPx = event.clientX - state.startX;\n\t\t\tconst deltaValue = pxToValueDelta(\n\t\t\t\tdeltaPx,\n\t\t\t\tpixelsPerStep,\n\t\t\t\tstate.activeStep\n\t\t\t);\n\t\t\tconst raw = state.startValue + deltaValue;\n\t\t\tconst stepped = quantize( raw, state.activeStep );\n\t\t\tconst next = clampValue( stepped, min, max );\n\t\t\tif ( next !== state.value ) {\n\t\t\t\t// Update the ref synchronously so consecutive pointermove\n\t\t\t\t// events that fire before React commits still see the\n\t\t\t\t// last *emitted* value as `previous` for the next math.\n\t\t\t\tstate.value = next;\n\t\t\t\tonChange( next );\n\t\t\t}\n\t\t},\n\t\t[ onChange, min, max, step, pixelsPerStep ]\n\t);\n\n\treturn {\n\t\tonPointerDown,\n\t\tonPointerMove,\n\t\tonPointerUp: endDrag,\n\t\tonPointerCancel: endDrag,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+C;AAaxC,SAAS,eACf,SACA,eACA,MACS;AACT,SAAS,CAAC,UAAU,gBAAkB;AACvC;AASO,SAAS,WAAY,OAAe,KAAa,KAAsB;AAC7E,MAAK,QAAQ,KAAM;AAClB,WAAO;AAAA,EACR;AACA,MAAK,QAAQ,KAAM;AAClB,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAQO,SAAS,SAAU,OAAe,MAAuB;AAC/D,SAAO,KAAK,MAAO,QAAQ,IAAK,IAAI;AACrC;AAoCO,SAAS,aACf,SACoB;AACpB,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAQJ,QAAM,gBAAY,uBASb;AAAA,IACJ;AAAA,IACA,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,IAClB,iBAAiB;AAAA,EAClB,CAAE;AACF,gCAAW,MAAM;AAChB,cAAU,QAAQ,QAAQ;AAAA,EAC3B,GAAG,CAAE,KAAM,CAAE;AAEb,QAAM,cAAU,4BAAa,MAAM;AAClC,UAAM,QAAQ,UAAU;AACxB,QAAK,CAAE,MAAM,UAAW;AACvB;AAAA,IACD;AACA,UAAM,WAAW;AACjB,QACC,MAAM,kBACN,MAAM,eAAe,kBAAmB,MAAM,gBAAiB,GAC9D;AACD,YAAM,eAAe;AAAA,QACpB,MAAM;AAAA,MACP;AAAA,IACD;AACA,UAAM,iBAAiB;AACvB,QAAK,MAAM,iBAAkB;AAC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AAS,MAAM,OAAQ;AAI3B,cAAM,QAAQ;AACd,iBAAU,IAAK;AAAA,MAChB;AAAA,IACD;AAAA,IACA,CAAE,UAAU,KAAK,KAAK,MAAM,aAAc;AAAA,EAC3C;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,iBAAiB;AAAA,EAClB;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/use-crop-gesture-handlers.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { useMediaEditor } from '../state';\n\n/**\n * Data attribute applied to crop control wrappers. The modal's keyboard\n * shortcut handler uses this to distinguish crop controls (where custom\n * undo/redo should fire) from metadata text fields (where the browser's\n * native undo should be preserved).\n */\nexport const CROP_CONTROL_ATTR = 'data-crop-control';\n\n/** Idle window used to group repeated keyboard input into one gesture. */\nconst KEYBOARD_GESTURE_IDLE_MS = 300;\n\nexport interface UseCropGestureHandlersOptions {\n\t/**\n\t * When `true` (default), key-up closes the gesture so each\n\t * discrete keypress becomes its own undo step. Set to `false` for\n\t * continuous-input controls (e.g. the rotation ruler) where rapid\n\t * keypresses should coalesce into a single history entry across\n\t * the whole gesture.\n\t */\n\tcommitOnKeyUp?: boolean;\n}\n\n/**\n * Event handler props to spread onto a wrapper element around a crop\n * control. Marks the wrapper as a crop control (via `data-crop-control`)\n * so the modal's Cmd+Z handler can identify it, and wires gesture\n * boundaries on the composite store so a slider drag becomes a single\n * undo entry rather than one per tick.\n *\n * Usage:\n * const gestureHandlers = useCropGestureHandlers();\n * <div role=\"presentation\" { ...gestureHandlers }>\n * <RangeControl ... />\n * </div>\n *\n * @param options Optional behavior flags.\n */\nexport function useCropGestureHandlers(\n\toptions: UseCropGestureHandlersOptions = {}\n) {\n\tconst { commitOnKeyUp = true } = options;\n\tconst { beginGesture, endGesture } = useMediaEditor();\n\tconst keyboardTimerRef = useRef< ReturnType< typeof setTimeout > >();\n\n\tconst clearKeyboardTimer = useCallback( () => {\n\t\tclearTimeout( keyboardTimerRef.current );\n\t}, [] );\n\n\tconst scheduleKeyboardEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tkeyboardTimerRef.current = setTimeout( () => {\n\t\t\tendGesture();\n\t\t}, KEYBOARD_GESTURE_IDLE_MS );\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tuseEffect( () => clearKeyboardTimer, [ clearKeyboardTimer ] );\n\n\tconst handlePointerDownCapture = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tbeginGesture();\n\t}, [ beginGesture, clearKeyboardTimer ] );\n\n\tconst handlePointerEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tendGesture();\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tconst handleKeyDownCapture = useCallback( () => {\n\t\tbeginGesture();\n\t\tif ( ! commitOnKeyUp ) {\n\t\t\tscheduleKeyboardEnd();\n\t\t}\n\t}, [ beginGesture, commitOnKeyUp, scheduleKeyboardEnd ] );\n\n\tconst handleKeyUp = useCallback( () => {\n\t\tif ( commitOnKeyUp ) {\n\t\t\tendGesture();\n\t\t\treturn;\n\t\t}\n\t\tscheduleKeyboardEnd();\n\t}, [ commitOnKeyUp, endGesture, scheduleKeyboardEnd ] );\n\n\treturn {\n\t\t[ CROP_CONTROL_ATTR ]: true,\n\t\tonPointerDownCapture: handlePointerDownCapture,\n\t\tonPointerUp: handlePointerEnd,\n\t\tonPointerCancel: handlePointerEnd,\n\t\tonKeyDownCapture: handleKeyDownCapture,\n\t\tonKeyUp: handleKeyUp,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;A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
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/image-editor/core/camera.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { mat2d, vec2 } from 'gl-matrix';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tCropperState,\n\tNormalizedPoint,\n\tNormalizedRect,\n\tSize,\n\tCamera,\n} from './types';\nimport { degreesToRadians } from './math/rotation';\nimport {\n\tisSafeNumber,\n\tisValidSize,\n\tsafeBoundedNumber,\n\tsanitizeCropperState,\n} from './math/sanitize';\n\n// Pre-allocated scratch buffers for `screenToWorld`, which is called per\n// pointermove. Module-level singletons — safe because usage is synchronous.\nconst _scratchMat = mat2d.create();\nconst _scratchVec = vec2.create();\n\n/**\n * Compute the axis-aligned bounding box of a rectangle after rotation.\n *\n * @param width The width of the rectangle.\n * @param height The height of the rectangle.\n * @param rotation The rotation angle in degrees.\n * @return The bounding box size after rotation.\n */\nexport function getRotatedBBox(\n\twidth: number,\n\theight: number,\n\trotation: number\n): Size {\n\t// Short-circuit on any unsafe input. `isSafeNumber` is stricter than\n\t// `Number.isFinite`: very large but technically-finite rotations (e.g.\n\t// `Number.MAX_VALUE`) overflow inside `degreesToRadians` and then\n\t// `Math.cos`/`Math.sin` return `NaN`, so the magnitude bound matters.\n\tif (\n\t\t! isSafeNumber( width ) ||\n\t\t! isSafeNumber( height ) ||\n\t\t! isSafeNumber( rotation ) ||\n\t\twidth <= 0 ||\n\t\theight <= 0\n\t) {\n\t\treturn { width: 0, height: 0 };\n\t}\n\tconst rad = degreesToRadians( rotation );\n\tconst cosR = Math.abs( Math.cos( rad ) );\n\tconst sinR = Math.abs( Math.sin( rad ) );\n\treturn {\n\t\twidth: cosR * width + sinR * height,\n\t\theight: sinR * width + cosR * height,\n\t};\n}\n\n/**\n * Compute the fitted (unrotated) image element dimensions and the visual\n * (rotated) bounding box dimensions for a given container, image, and rotation.\n *\n * This is the same \"contain\" fit logic used by createCamera, extracted so\n * cropper.tsx can size the <img> element and position overlays without\n * duplicating the math.\n *\n * @param containerSize The container dimensions in pixels.\n * @param imageSize The natural image dimensions in pixels.\n * @param rotation The rotation angle in degrees.\n * @return The fitted element size and visual bounding box size.\n */\nexport function getImageFit(\n\tcontainerSize: Size,\n\timageSize: Size,\n\trotation: number\n): { elementSize: Size; visualSize: Size } {\n\tif ( ! isValidSize( containerSize ) || ! isValidSize( imageSize ) ) {\n\t\treturn {\n\t\t\telementSize: { width: 0, height: 0 },\n\t\t\tvisualSize: { width: 0, height: 0 },\n\t\t};\n\t}\n\tconst safeRotation = safeBoundedNumber( rotation, 0 );\n\t// Snap rotation to the nearest 90° multiple for layout sizing.\n\t// This keeps the stencil a stable size through fine ±45° rotation\n\t// (no inflation at 15°/30° etc.) while still swapping aspect at\n\t// 90°/180°/270° so the snap rotate preserves the framed content.\n\tconst snapRotation = Math.round( safeRotation / 90 ) * 90;\n\tconst naturalBBox = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tsnapRotation\n\t);\n\t// Defensive: getRotatedBBox returns zero dims for hostile inputs, which\n\t// would make fitScale infinite. Mirror the zero-container short-circuit.\n\tif ( naturalBBox.width === 0 || naturalBBox.height === 0 ) {\n\t\treturn {\n\t\t\telementSize: { width: 0, height: 0 },\n\t\t\tvisualSize: { width: 0, height: 0 },\n\t\t};\n\t}\n\tconst fitScale = Math.min(\n\t\tcontainerSize.width / naturalBBox.width,\n\t\tcontainerSize.height / naturalBBox.height\n\t);\n\tconst renderedW = imageSize.width * fitScale;\n\tconst renderedH = imageSize.height * fitScale;\n\tconst visualSize = getRotatedBBox( renderedW, renderedH, snapRotation );\n\treturn {\n\t\telementSize: { width: renderedW, height: renderedH },\n\t\tvisualSize,\n\t};\n}\n\n/**\n * Resolve the presentational view magnification that makes the crop fill the\n * canvas.\n *\n * The crop overlay is laid out as `cropRect * visualSize` (the contain-fit\n * footprint, with no zoom), so its on-screen size is capped by that footprint.\n * When a crop's aspect differs from the image's, it can be much smaller than\n * the canvas could show (e.g. a square crop in a tall image is bound by the\n * footprint's narrow axis). Scaling `elementSize` and `visualSize` together by\n * the returned factor uniformly magnifies the whole scene — image, crop\n * overlay, and overlays — so the crop reaches `targetFill` of its constraining\n * canvas axis, with the image bleeding past the canvas (clipped by the host).\n *\n * Purely presentational: it does not touch `zoom`/`pan`/`cropRect`/`rotation`,\n * so the framed source region — and therefore the export — is unchanged.\n *\n * @param cropRect The crop rectangle, normalized to the footprint.\n * @param canvasSize The canvas size in pixels.\n * @param visualSize The contain-fit (rotated) image footprint in pixels.\n * @param targetFill Fraction of the constraining canvas axis to fill (0–1].\n * @param maxScale Upper bound on the magnification.\n * @return A magnification factor in [1, maxScale]; 1 when none is needed.\n */\nexport function getViewScale(\n\tcropRect: NormalizedRect,\n\tcanvasSize: Size,\n\tvisualSize: Size,\n\ttargetFill: number,\n\tmaxScale: number\n): number {\n\tconst cropScreenW = cropRect.width * visualSize.width;\n\tconst cropScreenH = cropRect.height * visualSize.height;\n\t// `> 0` comparisons (rather than `<= 0`) reject NaN as well as zero and\n\t// negatives, so a non-finite rect/dimension/scale can't propagate to a\n\t// `scale(NaN)`. `isValidSize` already guards finiteness of the sizes.\n\tif (\n\t\t! isValidSize( canvasSize ) ||\n\t\t! isValidSize( visualSize ) ||\n\t\t! ( cropScreenW > 0 ) ||\n\t\t! ( cropScreenH > 0 ) ||\n\t\t! Number.isFinite( targetFill ) ||\n\t\t! Number.isFinite( maxScale ) ||\n\t\t! ( targetFill > 0 ) ||\n\t\t! ( maxScale >= 1 )\n\t) {\n\t\treturn 1;\n\t}\n\tconst kW = ( targetFill * canvasSize.width ) / cropScreenW;\n\tconst kH = ( targetFill * canvasSize.height ) / cropScreenH;\n\tconst k = Math.min( kW, kH );\n\treturn Math.min( maxScale, Math.max( 1, k ) );\n}\n\n/**\n * Compose a camera matrix from cropper state, container, and image dimensions.\n *\n * The matrix maps normalized world coordinates [0,1] x [0,1] to screen pixels.\n * Input (0,0) = image top-left, (1,1) = image bottom-right.\n *\n * Composition order (left-to-right = outermost first, applied last to point):\n * M = T_containerCenter * T_pan * S_flip * R_rotation * S_zoom * T_center * S_toRenderedPixels\n *\n * Flip is composed outside rotation, so `flip.horizontal` / `flip.vertical`\n * are viewport-relative: the image mirrors across the viewport's vertical /\n * horizontal axis regardless of current rotation.\n *\n * @param state The current cropper state (zoom, rotation, flip, crop).\n * @param containerSize The size of the container in pixels.\n * @param imageSize The natural size of the image in pixels.\n * @return The composed camera matrix.\n */\nexport function createCamera(\n\tstate: CropperState,\n\tcontainerSize: Size,\n\timageSize: Size\n): Camera {\n\tconst m = mat2d.create();\n\n\tif ( ! isValidSize( containerSize ) || ! isValidSize( imageSize ) ) {\n\t\treturn m;\n\t}\n\n\tconst safeState = sanitizeCropperState( state );\n\n\t// Use the nearest 90° multiple for layout sizing so the stencil\n\t// and visual bounds are stable through fine rotation. The actual\n\t// `state.rotation` is still used for the rotation component of\n\t// the matrix below.\n\tconst snapRotation = Math.round( safeState.rotation / 90 ) * 90;\n\n\t// Rotated bounding box of the natural image (at snap angle).\n\tconst naturalBBox = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tsnapRotation\n\t);\n\n\t// Defensive: getRotatedBBox returns zero dims for unsafe inputs. Mirror\n\t// the zero-size short-circuit so `fitScale` doesn't become Infinity.\n\tif ( naturalBBox.width === 0 || naturalBBox.height === 0 ) {\n\t\treturn m;\n\t}\n\n\t// \"Contain\" fit: scale rotated bounding box to fit within container.\n\tconst fitScale = Math.min(\n\t\tcontainerSize.width / naturalBBox.width,\n\t\tcontainerSize.height / naturalBBox.height\n\t);\n\n\t// The rendered (unrotated) image dimensions at this fit scale.\n\tconst renderedW = imageSize.width * fitScale;\n\tconst renderedH = imageSize.height * fitScale;\n\n\t// Visual (rotated) image footprint in pixels (at snap angle).\n\tconst { width: visualW, height: visualH } = getRotatedBBox(\n\t\trenderedW,\n\t\trenderedH,\n\t\tsnapRotation\n\t);\n\n\t// Build matrix left-to-right (outermost first).\n\t// Innermost operations (last in code) are applied first to input point.\n\n\t// Outermost: translate to container center.\n\tmat2d.translate( m, m, [\n\t\tcontainerSize.width / 2,\n\t\tcontainerSize.height / 2,\n\t] );\n\n\t// Pan offset in visual-space pixels.\n\tmat2d.translate( m, m, [\n\t\tsafeState.pan.x * visualW,\n\t\tsafeState.pan.y * visualH,\n\t] );\n\n\t// Flip (viewport-relative — composed outside rotation so horizontal\n\t// flip always mirrors across the viewport's vertical axis).\n\tmat2d.scale( m, m, [\n\t\tsafeState.flip.horizontal ? -1 : 1,\n\t\tsafeState.flip.vertical ? -1 : 1,\n\t] );\n\n\t// Rotate.\n\tmat2d.rotate( m, m, degreesToRadians( safeState.rotation ) );\n\n\t// Zoom.\n\tmat2d.scale( m, m, [ safeState.zoom, safeState.zoom ] );\n\n\t// Center origin (shift so 0.5,0.5 in rendered-pixel space = origin).\n\tmat2d.translate( m, m, [ -renderedW / 2, -renderedH / 2 ] );\n\n\t// Innermost: scale from normalized [0,1] to rendered pixels.\n\tmat2d.scale( m, m, [ renderedW, renderedH ] );\n\n\treturn m;\n}\n\n/**\n * Transform a normalized world point [0,1] to screen pixels.\n *\n * @param camera The camera matrix from createCamera.\n * @param point The normalized world coordinate to transform.\n * @return The screen pixel coordinate.\n */\nexport function worldToScreen(\n\tcamera: Camera,\n\tpoint: NormalizedPoint\n): { x: number; y: number } {\n\tconst out = vec2.create();\n\tvec2.transformMat2d( out, [ point.x, point.y ], camera );\n\treturn { x: out[ 0 ], y: out[ 1 ] };\n}\n\n/**\n * Transform a screen pixel point to normalized world coordinates [0,1].\n *\n * @param camera The camera matrix from createCamera.\n * @param point The screen pixel coordinate to transform.\n * @param point.x The x component of the screen pixel coordinate.\n * @param point.y The y component of the screen pixel coordinate.\n * @return The normalized world coordinate.\n */\nexport function screenToWorld(\n\tcamera: Camera,\n\tpoint: { x: number; y: number }\n): NormalizedPoint {\n\tmat2d.invert( _scratchMat, camera );\n\tconst out = _scratchVec;\n\tvec2.transformMat2d( out, [ point.x, point.y ], _scratchMat );\n\treturn { x: out[ 0 ], y: out[ 1 ] };\n}\n\n/**\n * The bounding box of a transformed region in screen (pixel) space.\n */\nexport interface VisualBounds {\n\tleft: number;\n\ttop: number;\n\twidth: number;\n\theight: number;\n}\n\n/**\n * Compute the axis-aligned bounding box of a set of corners after\n * transforming them through a camera matrix.\n *\n * @param camera The camera matrix from createCamera.\n * @param corners The corners to transform (each as [x, y]).\n * @return The screen-space bounding box.\n */\nfunction aabb( camera: Camera, corners: [ number, number ][] ): VisualBounds {\n\tconst screenCorners = corners.map( ( c ) => {\n\t\tconst out = vec2.create();\n\t\tvec2.transformMat2d( out, c, camera );\n\t\treturn out;\n\t} );\n\tlet minX = screenCorners[ 0 ][ 0 ];\n\tlet maxX = screenCorners[ 0 ][ 0 ];\n\tlet minY = screenCorners[ 0 ][ 1 ];\n\tlet maxY = screenCorners[ 0 ][ 1 ];\n\tfor ( let i = 1; i < screenCorners.length; i++ ) {\n\t\tconst s = screenCorners[ i ];\n\t\tif ( s[ 0 ] < minX ) {\n\t\t\tminX = s[ 0 ];\n\t\t}\n\t\tif ( s[ 0 ] > maxX ) {\n\t\t\tmaxX = s[ 0 ];\n\t\t}\n\t\tif ( s[ 1 ] < minY ) {\n\t\t\tminY = s[ 1 ];\n\t\t}\n\t\tif ( s[ 1 ] > maxY ) {\n\t\t\tmaxY = s[ 1 ];\n\t\t}\n\t}\n\treturn { left: minX, top: minY, width: maxX - minX, height: maxY - minY };\n}\n\n/**\n * Returns the axis-aligned bounding box of the full image (normalized [0,1]x[0,1])\n * after applying the camera transform.\n *\n * @param camera The camera matrix from createCamera.\n * @return The screen-space bounding box of the full image.\n */\nexport function getVisibleBounds( camera: Camera ): VisualBounds {\n\treturn aabb( camera, [\n\t\t[ 0, 0 ],\n\t\t[ 1, 0 ],\n\t\t[ 1, 1 ],\n\t\t[ 0, 1 ],\n\t] );\n}\n\n/**\n * Compose a camera matrix for exporting to a canvas.\n *\n * The resulting matrix maps image-pixel coordinates directly to output-canvas\n * coordinates. Apply it with `ctx.setTransform( ...camera )` then\n * `ctx.drawImage( image, 0, 0 )`.\n *\n * The transform chain mirrors the `renderToCanvas` function in canvas-renderer.ts:\n * translate(visualCenter - cropOffset + outCenter) → flip → rotate → zoom → translate(-imgCenter)\n *\n * @param state The current cropper state.\n * @param imageSize The natural size of the source image in pixels.\n * @param outputSize The desired output canvas size in pixels.\n * @return The composed export camera matrix.\n */\nexport function createExportCamera(\n\tstate: CropperState,\n\timageSize: Size,\n\toutputSize: Size\n): Camera {\n\tconst m = mat2d.create();\n\tif ( ! isValidSize( imageSize ) || ! isValidSize( outputSize ) ) {\n\t\treturn m;\n\t}\n\tconst { rotation, flip, cropRect, zoom, pan } =\n\t\tsanitizeCropperState( state );\n\t// Reference frame for cropRect/pan is the snap-rotation bbox — that's\n\t// what the stencil and CSS matrix use in the preview (see createCamera\n\t// and getImageFit). Using the true rotation here would position the\n\t// crop window at a different offset than the stencil framed, and show\n\t// a shifted region after any fine rotation.\n\tconst snapRotation = Math.round( rotation / 90 ) * 90;\n\tconst { width: rotW, height: rotH } = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tsnapRotation\n\t);\n\n\t// Scale factor to map the natural crop region to the output canvas size.\n\tconst naturalCropW = cropRect.width * rotW;\n\tconst naturalCropH = cropRect.height * rotH;\n\tconst outputScaleX = naturalCropW > 0 ? outputSize.width / naturalCropW : 1;\n\tconst outputScaleY =\n\t\tnaturalCropH > 0 ? outputSize.height / naturalCropH : 1;\n\n\tconst cropOffsetX = cropRect.x * rotW + outputSize.width / 2 / outputScaleX;\n\tconst cropOffsetY =\n\t\tcropRect.y * rotH + outputSize.height / 2 / outputScaleY;\n\tconst visualCenterX = rotW / 2 + pan.x * rotW;\n\tconst visualCenterY = rotH / 2 + pan.y * rotH;\n\tmat2d.scale( m, m, [ outputScaleX, outputScaleY ] );\n\tmat2d.translate( m, m, [\n\t\tvisualCenterX - cropOffsetX + outputSize.width / 2 / outputScaleX,\n\t\tvisualCenterY - cropOffsetY + outputSize.height / 2 / outputScaleY,\n\t] );\n\t// Flip is composed outside rotation so it acts in viewport/output space —\n\t// must match createCamera's order for preview and export to agree.\n\tmat2d.scale( m, m, [ flip.horizontal ? -1 : 1, flip.vertical ? -1 : 1 ] );\n\tmat2d.rotate( m, m, degreesToRadians( rotation ) );\n\tmat2d.scale( m, m, [ zoom, zoom ] );\n\tmat2d.translate( m, m, [ -imageSize.width / 2, -imageSize.height / 2 ] );\n\treturn m;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { mat2d, vec2 } from 'gl-matrix';\nimport type {\n\tCropperState,\n\tNormalizedPoint,\n\tNormalizedRect,\n\tSize,\n\tCamera,\n} from './types';\nimport { degreesToRadians } from './math/rotation';\nimport {\n\tisSafeNumber,\n\tisValidSize,\n\tsafeBoundedNumber,\n\tsanitizeCropperState,\n} from './math/sanitize';\n\n// Pre-allocated scratch buffers for `screenToWorld`, which is called per\n// pointermove. Module-level singletons — safe because usage is synchronous.\nconst _scratchMat = mat2d.create();\nconst _scratchVec = vec2.create();\n\n/**\n * Compute the axis-aligned bounding box of a rectangle after rotation.\n *\n * @param width The width of the rectangle.\n * @param height The height of the rectangle.\n * @param rotation The rotation angle in degrees.\n * @return The bounding box size after rotation.\n */\nexport function getRotatedBBox(\n\twidth: number,\n\theight: number,\n\trotation: number\n): Size {\n\t// Short-circuit on any unsafe input. `isSafeNumber` is stricter than\n\t// `Number.isFinite`: very large but technically-finite rotations (e.g.\n\t// `Number.MAX_VALUE`) overflow inside `degreesToRadians` and then\n\t// `Math.cos`/`Math.sin` return `NaN`, so the magnitude bound matters.\n\tif (\n\t\t! isSafeNumber( width ) ||\n\t\t! isSafeNumber( height ) ||\n\t\t! isSafeNumber( rotation ) ||\n\t\twidth <= 0 ||\n\t\theight <= 0\n\t) {\n\t\treturn { width: 0, height: 0 };\n\t}\n\tconst rad = degreesToRadians( rotation );\n\tconst cosR = Math.abs( Math.cos( rad ) );\n\tconst sinR = Math.abs( Math.sin( rad ) );\n\treturn {\n\t\twidth: cosR * width + sinR * height,\n\t\theight: sinR * width + cosR * height,\n\t};\n}\n\n/**\n * Compute the fitted (unrotated) image element dimensions and the visual\n * (rotated) bounding box dimensions for a given container, image, and rotation.\n *\n * This is the same \"contain\" fit logic used by createCamera, extracted so\n * cropper.tsx can size the <img> element and position overlays without\n * duplicating the math.\n *\n * @param containerSize The container dimensions in pixels.\n * @param imageSize The natural image dimensions in pixels.\n * @param rotation The rotation angle in degrees.\n * @return The fitted element size and visual bounding box size.\n */\nexport function getImageFit(\n\tcontainerSize: Size,\n\timageSize: Size,\n\trotation: number\n): { elementSize: Size; visualSize: Size } {\n\tif ( ! isValidSize( containerSize ) || ! isValidSize( imageSize ) ) {\n\t\treturn {\n\t\t\telementSize: { width: 0, height: 0 },\n\t\t\tvisualSize: { width: 0, height: 0 },\n\t\t};\n\t}\n\tconst safeRotation = safeBoundedNumber( rotation, 0 );\n\t// Snap rotation to the nearest 90° multiple for layout sizing.\n\t// This keeps the stencil a stable size through fine ±45° rotation\n\t// (no inflation at 15°/30° etc.) while still swapping aspect at\n\t// 90°/180°/270° so the snap rotate preserves the framed content.\n\tconst snapRotation = Math.round( safeRotation / 90 ) * 90;\n\tconst naturalBBox = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tsnapRotation\n\t);\n\t// Defensive: getRotatedBBox returns zero dims for hostile inputs, which\n\t// would make fitScale infinite. Mirror the zero-container short-circuit.\n\tif ( naturalBBox.width === 0 || naturalBBox.height === 0 ) {\n\t\treturn {\n\t\t\telementSize: { width: 0, height: 0 },\n\t\t\tvisualSize: { width: 0, height: 0 },\n\t\t};\n\t}\n\tconst fitScale = Math.min(\n\t\tcontainerSize.width / naturalBBox.width,\n\t\tcontainerSize.height / naturalBBox.height\n\t);\n\tconst renderedW = imageSize.width * fitScale;\n\tconst renderedH = imageSize.height * fitScale;\n\tconst visualSize = getRotatedBBox( renderedW, renderedH, snapRotation );\n\treturn {\n\t\telementSize: { width: renderedW, height: renderedH },\n\t\tvisualSize,\n\t};\n}\n\n/**\n * Resolve the presentational view magnification that makes the crop fill the\n * canvas.\n *\n * The crop overlay is laid out as `cropRect * visualSize` (the contain-fit\n * footprint, with no zoom), so its on-screen size is capped by that footprint.\n * When a crop's aspect differs from the image's, it can be much smaller than\n * the canvas could show (e.g. a square crop in a tall image is bound by the\n * footprint's narrow axis). Scaling `elementSize` and `visualSize` together by\n * the returned factor uniformly magnifies the whole scene — image, crop\n * overlay, and overlays — so the crop reaches `targetFill` of its constraining\n * canvas axis, with the image bleeding past the canvas (clipped by the host).\n *\n * Purely presentational: it does not touch `zoom`/`pan`/`cropRect`/`rotation`,\n * so the framed source region — and therefore the export — is unchanged.\n *\n * @param cropRect The crop rectangle, normalized to the footprint.\n * @param canvasSize The canvas size in pixels.\n * @param visualSize The contain-fit (rotated) image footprint in pixels.\n * @param targetFill Fraction of the constraining canvas axis to fill (0–1].\n * @param maxScale Upper bound on the magnification.\n * @return A magnification factor in [1, maxScale]; 1 when none is needed.\n */\nexport function getViewScale(\n\tcropRect: NormalizedRect,\n\tcanvasSize: Size,\n\tvisualSize: Size,\n\ttargetFill: number,\n\tmaxScale: number\n): number {\n\tconst cropScreenW = cropRect.width * visualSize.width;\n\tconst cropScreenH = cropRect.height * visualSize.height;\n\t// `> 0` comparisons (rather than `<= 0`) reject NaN as well as zero and\n\t// negatives, so a non-finite rect/dimension/scale can't propagate to a\n\t// `scale(NaN)`. `isValidSize` already guards finiteness of the sizes.\n\tif (\n\t\t! isValidSize( canvasSize ) ||\n\t\t! isValidSize( visualSize ) ||\n\t\t! ( cropScreenW > 0 ) ||\n\t\t! ( cropScreenH > 0 ) ||\n\t\t! Number.isFinite( targetFill ) ||\n\t\t! Number.isFinite( maxScale ) ||\n\t\t! ( targetFill > 0 ) ||\n\t\t! ( maxScale >= 1 )\n\t) {\n\t\treturn 1;\n\t}\n\tconst kW = ( targetFill * canvasSize.width ) / cropScreenW;\n\tconst kH = ( targetFill * canvasSize.height ) / cropScreenH;\n\tconst k = Math.min( kW, kH );\n\treturn Math.min( maxScale, Math.max( 1, k ) );\n}\n\n/**\n * Compose a camera matrix from cropper state, container, and image dimensions.\n *\n * The matrix maps normalized world coordinates [0,1] x [0,1] to screen pixels.\n * Input (0,0) = image top-left, (1,1) = image bottom-right.\n *\n * Composition order (left-to-right = outermost first, applied last to point):\n * M = T_containerCenter * T_pan * S_flip * R_rotation * S_zoom * T_center * S_toRenderedPixels\n *\n * Flip is composed outside rotation, so `flip.horizontal` / `flip.vertical`\n * are viewport-relative: the image mirrors across the viewport's vertical /\n * horizontal axis regardless of current rotation.\n *\n * @param state The current cropper state (zoom, rotation, flip, crop).\n * @param containerSize The size of the container in pixels.\n * @param imageSize The natural size of the image in pixels.\n * @return The composed camera matrix.\n */\nexport function createCamera(\n\tstate: CropperState,\n\tcontainerSize: Size,\n\timageSize: Size\n): Camera {\n\tconst m = mat2d.create();\n\n\tif ( ! isValidSize( containerSize ) || ! isValidSize( imageSize ) ) {\n\t\treturn m;\n\t}\n\n\tconst safeState = sanitizeCropperState( state );\n\n\t// Use the nearest 90° multiple for layout sizing so the stencil\n\t// and visual bounds are stable through fine rotation. The actual\n\t// `state.rotation` is still used for the rotation component of\n\t// the matrix below.\n\tconst snapRotation = Math.round( safeState.rotation / 90 ) * 90;\n\n\t// Rotated bounding box of the natural image (at snap angle).\n\tconst naturalBBox = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tsnapRotation\n\t);\n\n\t// Defensive: getRotatedBBox returns zero dims for unsafe inputs. Mirror\n\t// the zero-size short-circuit so `fitScale` doesn't become Infinity.\n\tif ( naturalBBox.width === 0 || naturalBBox.height === 0 ) {\n\t\treturn m;\n\t}\n\n\t// \"Contain\" fit: scale rotated bounding box to fit within container.\n\tconst fitScale = Math.min(\n\t\tcontainerSize.width / naturalBBox.width,\n\t\tcontainerSize.height / naturalBBox.height\n\t);\n\n\t// The rendered (unrotated) image dimensions at this fit scale.\n\tconst renderedW = imageSize.width * fitScale;\n\tconst renderedH = imageSize.height * fitScale;\n\n\t// Visual (rotated) image footprint in pixels (at snap angle).\n\tconst { width: visualW, height: visualH } = getRotatedBBox(\n\t\trenderedW,\n\t\trenderedH,\n\t\tsnapRotation\n\t);\n\n\t// Build matrix left-to-right (outermost first).\n\t// Innermost operations (last in code) are applied first to input point.\n\n\t// Outermost: translate to container center.\n\tmat2d.translate( m, m, [\n\t\tcontainerSize.width / 2,\n\t\tcontainerSize.height / 2,\n\t] );\n\n\t// Pan offset in visual-space pixels.\n\tmat2d.translate( m, m, [\n\t\tsafeState.pan.x * visualW,\n\t\tsafeState.pan.y * visualH,\n\t] );\n\n\t// Flip (viewport-relative — composed outside rotation so horizontal\n\t// flip always mirrors across the viewport's vertical axis).\n\tmat2d.scale( m, m, [\n\t\tsafeState.flip.horizontal ? -1 : 1,\n\t\tsafeState.flip.vertical ? -1 : 1,\n\t] );\n\n\t// Rotate.\n\tmat2d.rotate( m, m, degreesToRadians( safeState.rotation ) );\n\n\t// Zoom.\n\tmat2d.scale( m, m, [ safeState.zoom, safeState.zoom ] );\n\n\t// Center origin (shift so 0.5,0.5 in rendered-pixel space = origin).\n\tmat2d.translate( m, m, [ -renderedW / 2, -renderedH / 2 ] );\n\n\t// Innermost: scale from normalized [0,1] to rendered pixels.\n\tmat2d.scale( m, m, [ renderedW, renderedH ] );\n\n\treturn m;\n}\n\n/**\n * Transform a normalized world point [0,1] to screen pixels.\n *\n * @param camera The camera matrix from createCamera.\n * @param point The normalized world coordinate to transform.\n * @return The screen pixel coordinate.\n */\nexport function worldToScreen(\n\tcamera: Camera,\n\tpoint: NormalizedPoint\n): { x: number; y: number } {\n\tconst out = vec2.create();\n\tvec2.transformMat2d( out, [ point.x, point.y ], camera );\n\treturn { x: out[ 0 ], y: out[ 1 ] };\n}\n\n/**\n * Transform a screen pixel point to normalized world coordinates [0,1].\n *\n * @param camera The camera matrix from createCamera.\n * @param point The screen pixel coordinate to transform.\n * @param point.x The x component of the screen pixel coordinate.\n * @param point.y The y component of the screen pixel coordinate.\n * @return The normalized world coordinate.\n */\nexport function screenToWorld(\n\tcamera: Camera,\n\tpoint: { x: number; y: number }\n): NormalizedPoint {\n\tmat2d.invert( _scratchMat, camera );\n\tconst out = _scratchVec;\n\tvec2.transformMat2d( out, [ point.x, point.y ], _scratchMat );\n\treturn { x: out[ 0 ], y: out[ 1 ] };\n}\n\n/**\n * The bounding box of a transformed region in screen (pixel) space.\n */\nexport interface VisualBounds {\n\tleft: number;\n\ttop: number;\n\twidth: number;\n\theight: number;\n}\n\n/**\n * Compute the axis-aligned bounding box of a set of corners after\n * transforming them through a camera matrix.\n *\n * @param camera The camera matrix from createCamera.\n * @param corners The corners to transform (each as [x, y]).\n * @return The screen-space bounding box.\n */\nfunction aabb( camera: Camera, corners: [ number, number ][] ): VisualBounds {\n\tconst screenCorners = corners.map( ( c ) => {\n\t\tconst out = vec2.create();\n\t\tvec2.transformMat2d( out, c, camera );\n\t\treturn out;\n\t} );\n\tlet minX = screenCorners[ 0 ][ 0 ];\n\tlet maxX = screenCorners[ 0 ][ 0 ];\n\tlet minY = screenCorners[ 0 ][ 1 ];\n\tlet maxY = screenCorners[ 0 ][ 1 ];\n\tfor ( let i = 1; i < screenCorners.length; i++ ) {\n\t\tconst s = screenCorners[ i ];\n\t\tif ( s[ 0 ] < minX ) {\n\t\t\tminX = s[ 0 ];\n\t\t}\n\t\tif ( s[ 0 ] > maxX ) {\n\t\t\tmaxX = s[ 0 ];\n\t\t}\n\t\tif ( s[ 1 ] < minY ) {\n\t\t\tminY = s[ 1 ];\n\t\t}\n\t\tif ( s[ 1 ] > maxY ) {\n\t\t\tmaxY = s[ 1 ];\n\t\t}\n\t}\n\treturn { left: minX, top: minY, width: maxX - minX, height: maxY - minY };\n}\n\n/**\n * Returns the axis-aligned bounding box of the full image (normalized [0,1]x[0,1])\n * after applying the camera transform.\n *\n * @param camera The camera matrix from createCamera.\n * @return The screen-space bounding box of the full image.\n */\nexport function getVisibleBounds( camera: Camera ): VisualBounds {\n\treturn aabb( camera, [\n\t\t[ 0, 0 ],\n\t\t[ 1, 0 ],\n\t\t[ 1, 1 ],\n\t\t[ 0, 1 ],\n\t] );\n}\n\n/**\n * Compose a camera matrix for exporting to a canvas.\n *\n * The resulting matrix maps image-pixel coordinates directly to output-canvas\n * coordinates. Apply it with `ctx.setTransform( ...camera )` then\n * `ctx.drawImage( image, 0, 0 )`.\n *\n * The transform chain mirrors the `renderToCanvas` function in canvas-renderer.ts:\n * translate(visualCenter - cropOffset + outCenter) → flip → rotate → zoom → translate(-imgCenter)\n *\n * @param state The current cropper state.\n * @param imageSize The natural size of the source image in pixels.\n * @param outputSize The desired output canvas size in pixels.\n * @return The composed export camera matrix.\n */\nexport function createExportCamera(\n\tstate: CropperState,\n\timageSize: Size,\n\toutputSize: Size\n): Camera {\n\tconst m = mat2d.create();\n\tif ( ! isValidSize( imageSize ) || ! isValidSize( outputSize ) ) {\n\t\treturn m;\n\t}\n\tconst { rotation, flip, cropRect, zoom, pan } =\n\t\tsanitizeCropperState( state );\n\t// Reference frame for cropRect/pan is the snap-rotation bbox — that's\n\t// what the stencil and CSS matrix use in the preview (see createCamera\n\t// and getImageFit). Using the true rotation here would position the\n\t// crop window at a different offset than the stencil framed, and show\n\t// a shifted region after any fine rotation.\n\tconst snapRotation = Math.round( rotation / 90 ) * 90;\n\tconst { width: rotW, height: rotH } = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tsnapRotation\n\t);\n\n\t// Scale factor to map the natural crop region to the output canvas size.\n\tconst naturalCropW = cropRect.width * rotW;\n\tconst naturalCropH = cropRect.height * rotH;\n\tconst outputScaleX = naturalCropW > 0 ? outputSize.width / naturalCropW : 1;\n\tconst outputScaleY =\n\t\tnaturalCropH > 0 ? outputSize.height / naturalCropH : 1;\n\n\tconst cropOffsetX = cropRect.x * rotW + outputSize.width / 2 / outputScaleX;\n\tconst cropOffsetY =\n\t\tcropRect.y * rotH + outputSize.height / 2 / outputScaleY;\n\tconst visualCenterX = rotW / 2 + pan.x * rotW;\n\tconst visualCenterY = rotH / 2 + pan.y * rotH;\n\tmat2d.scale( m, m, [ outputScaleX, outputScaleY ] );\n\tmat2d.translate( m, m, [\n\t\tvisualCenterX - cropOffsetX + outputSize.width / 2 / outputScaleX,\n\t\tvisualCenterY - cropOffsetY + outputSize.height / 2 / outputScaleY,\n\t] );\n\t// Flip is composed outside rotation so it acts in viewport/output space —\n\t// must match createCamera's order for preview and export to agree.\n\tmat2d.scale( m, m, [ flip.horizontal ? -1 : 1, flip.vertical ? -1 : 1 ] );\n\tmat2d.rotate( m, m, degreesToRadians( rotation ) );\n\tmat2d.scale( m, m, [ zoom, zoom ] );\n\tmat2d.translate( m, m, [ -imageSize.width / 2, -imageSize.height / 2 ] );\n\treturn m;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA4B;AAQ5B,sBAAiC;AACjC,sBAKO;AAIP,IAAM,cAAc,uBAAM,OAAO;AACjC,IAAM,cAAc,sBAAK,OAAO;AAUzB,SAAS,eACf,OACA,QACA,UACO;AAKP,MACC,KAAE,8BAAc,KAAM,KACtB,KAAE,8BAAc,MAAO,KACvB,KAAE,8BAAc,QAAS,KACzB,SAAS,KACT,UAAU,GACT;AACD,WAAO,EAAE,OAAO,GAAG,QAAQ,EAAE;AAAA,EAC9B;AACA,QAAM,UAAM,kCAAkB,QAAS;AACvC,QAAM,OAAO,KAAK,IAAK,KAAK,IAAK,GAAI,CAA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AI,IAAI,IAAI;AACzC,yBAAM,MAAO,GAAG,GAAG,CAAE,cAAc,YAAa,CAAE;AAClD,yBAAM,UAAW,GAAG,GAAG;AAAA,IACtB,gBAAgB,cAAc,WAAW,QAAQ,IAAI;AAAA,IACrD,gBAAgB,cAAc,WAAW,SAAS,IAAI;AAAA,EACvD,CAAE;AAGF,yBAAM,MAAO,GAAG,GAAG,CAAE,KAAK,aAAa,KAAK,GAAG,KAAK,WAAW,KAAK,CAAE,CAAE;AACxE,yBAAM,OAAQ,GAAG,OAAG,kCAAkB,QAAS,CAAE;AACjD,yBAAM,MAAO,GAAG,GAAG,CAAE,MAAM,IAAK,CAAE;AAClC,yBAAM,UAAW,GAAG,GAAG,CAAE,CAAC,UAAU,QAAQ,GAAG,CAAC,UAAU,SAAS,CAAE,CAAE;AACvE,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/image-editor/core/constants.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { NormalizedRect, Flip, CropperState } from './types';\n\n/**\n * Default/resting zoom. A full, unrotated crop needs at least 1x to cover the\n * crop area, but smaller/fine-rotated crops can be valid below 1x — the true\n * floor for those comes from `getMinZoom`.\n */\nexport const MIN_ZOOM = 1;\n/**\n * Safety floor for coverage-aware zoom. Degenerate crops can have a geometric\n * coverage minimum of 0, but camera and inverse-matrix math need a stable,\n * positive scale.\n */\nexport const ABSOLUTE_MIN_ZOOM = 0.1;\nexport const MAX_ZOOM = 10;\n\n/**\n * Minimum crop rect dimension in source-image pixels, enforced per axis\n * during resize. Prevents accidental sub-pixel crops while staying small\n * enough to allow tight crops (favicons, icons). Adjust here to tune the\n * floor globally.\n */\nexport const MIN_CROP_PIXELS = 16;\n\n/**\n * Minimum on-screen crop rect dimension in CSS pixels. The source-pixel\n * floor (`MIN_CROP_PIXELS`) keeps crops from going sub-pixel, but on a large\n * image fit into a small canvas it can render only a few CSS pixels wide —\n * too small to grab the resize handles. This floor keeps the crop operable\n * regardless of display scale; it binds when zoomed out and yields to the\n * source-pixel floor once the image is shown large enough. Sized to one\n * handle touch target (`$handle-touch-target-size` in `cropper.scss`).\n */\nexport const MIN_CROP_SCREEN_PX = 44;\n\n/**\n * Fraction of the constraining canvas axis the settled crop should occupy on\n * screen. When a crop is shown smaller than this (e.g. a square crop in a tall\n * image, capped by the contain-fit footprint's narrow axis), the view magnifies\n * to fill the canvas. `1` = always fill the canvas; lower = rescue only the\n * under-filled cases. See `getViewScale`.\n */\nexport const SETTLE_TARGET_CANVAS_FILL = 0.8;\n\n/**\n * Upper bound on the presentational view magnification (`getViewScale`).\n * Prevents a near-degenerate crop from magnifying the scene without limit.\n */\nexport const MAX_VIEW_SCALE = 8;\n\n/**\n * CSS pixels per source pixel required before resize handles snap the selected\n * source region to whole-pixel edges. Below 1:1, a source pixel is sub-pixel on\n * screen, so snapping would feel notchy without a visible pixel boundary.\n */\nexport const PIXEL_SNAP_DISPLAY_SCALE = 1;\n\n/**\n * Wheel zoom sensitivity. A deltaY of 100 changes zoom by 0.25.\n * This could be made configurable as a prop to the Cropper component.\n */\nexport const DEFAULT_WHEEL_ZOOM_SPEED = 0.0025;\n\n/** Fine step for keyboard-driven cropper movement, in normalized coordinates. */\nexport const DEFAULT_KEYBOARD_STEP = 0.01;\n\n/** Coarse keyboard movement multiplier when Shift is held. */\nexport const KEYBOARD_SHIFT_STEP_MULTIPLIER = 10;\n\n/**\n * Maximum free-rotation offset in degrees from the nearest 90° step.\n * The rotation slider allows ±45° around the current cardinal angle.\n */\nexport const MAX_ROTATION_OFFSET = 45;\n\nconst DEFAULT_CROP_RECT: NormalizedRect = {\n\tx: 0,\n\ty: 0,\n\twidth: 1,\n\theight: 1,\n};\n\nconst DEFAULT_FLIP: Flip = {\n\thorizontal: false,\n\tvertical: false,\n};\n\nconst DEFAULT_PAN: { x: number; y: number } = {\n\tx: 0,\n\ty: 0,\n};\n\nexport const DEFAULT_STATE: CropperState = {\n\timage: null,\n\tpan: { ...DEFAULT_PAN },\n\tzoom: MIN_ZOOM,\n\trotation: 0,\n\tbasePan: { ...DEFAULT_PAN },\n\tbaseZoom: MIN_ZOOM,\n\tbaseRotation: 0,\n\tflip: { ...DEFAULT_FLIP },\n\tcropRect: { ...DEFAULT_CROP_RECT },\n};\n\n/**\n * An aspect ratio preset with a human-readable label.\n */\nexport interface AspectRatioPreset {\n\t/** Display label (e.g., \"Square (1:1)\"). */\n\tlabel: string;\n\t/** The aspect ratio value (width / height). 0 = free / original. */\n\tvalue: number;\n}\n\n/**\n * Default aspect ratio presets. Consumers can use these as-is, override\n * with their own list, or extend with additional presets.\n *\n * @example\n * // Use defaults:\n * <CropControls presets={ DEFAULT_ASPECT_RATIOS } />\n *\n * // Custom presets:\n * const socialPresets = [\n * { label: 'Instagram Post', value: 1 },\n * { label: 'Instagram Story', value: 9 / 16 },\n * { label: 'YouTube Thumbnail', value: 16 / 9 },\n * ];\n *\n * // Extend defaults:\n * const extended = [ ...DEFAULT_ASPECT_RATIOS, { label: 'Cinema (21:9)', value: 21 / 9 } ];\n */\n/**\n * Sentinel value for \"Original\" aspect ratio — resolved at runtime\n * to the image's natural width / height.\n */\nexport const ORIGINAL_ASPECT_RATIO = -1;\n\nexport const DEFAULT_ASPECT_RATIOS: AspectRatioPreset[] = [\n\t{ label: __( 'Free' ), value: 0 },\n\t{ label: __( 'Original' ), value: ORIGINAL_ASPECT_RATIO },\n\t{ label: __( 'Square (1:1)' ), value: 1 },\n\t{ label: __( 'Landscape (16:9)' ), value: 16 / 9 },\n\t{ label: __( 'Portrait (9:16)' ), value: 9 / 16 },\n\t{ label: __( 'Classic (4:3)' ), value: 4 / 3 },\n\t{ label: __( 'Classic portrait (3:4)' ), value: 3 / 4 },\n\t{ label: __( 'Photo (3:2)' ), value: 3 / 2 },\n\t{ label: __( 'Photo portrait (2:3)' ), value: 2 / 3 },\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AAQZ,IAAM,WAAW;AAMjB,IAAM,oBAAoB;AAC1B,IAAM,WAAW;AAQjB,IAAM,kBAAkB;AAWxB,IAAM,qBAAqB;AAS3B,IAAM,4BAA4B;AAMlC,IAAM,iBAAiB;AAOvB,IAAM,2BAA2B;AAMjC,IAAM,2BAA2B;AAGjC,IAAM,wBAAwB;AAG9B,IAAM,iCAAiC;AAMvC,IAAM,sBAAsB;AAEnC,IAAM,oBAAoC;AAAA,EACzC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,OAAO;AAAA,EACP,QAAQ;AACT;AAEA,IAAM,eAAqB;AAAA,EAC1B,YAAY;AAAA,EACZ,UAAU;AACX;AAEA,IAAM,cAAwC;AAAA,EAC7C,GAAG;AAAA,EACH,GAAG;AACJ;AAEO,IAAM,gBAA8B;AAAA,EAC1C,OAAO;AAAA,EACP,KAAK,EAAE,GAAG,YAAY;AAAA,EACtB,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS,EAAE,GAAG,YAAY;AAAA,EAC1B,UAAU;AAAA,EACV,cAAc;AAAA,EACd,MAAM,EAAE,GAAG,aAAa;AAAA,EACxB,UAAU,EAAE,GAAG,kBAAkB;AAClC;AAkCO,IAAM,wBAAwB;AAE9B,IAAM,wBAA6C;AAAA,EACzD,EAAE,WAAO,gBAAI,MAAO,GAAG,OAAO,EAAE;AAAA,EAChC,EAAE,WAAO,gB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