@wordpress/media-editor 0.7.1-next.v.202604201441.0 → 0.8.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/build/components/media-editor-canvas/index.cjs +54 -0
- package/build/components/media-editor-canvas/index.cjs.map +7 -0
- package/build/components/media-editor-crop-panel/index.cjs +116 -0
- package/build/components/media-editor-crop-panel/index.cjs.map +7 -0
- package/build/components/media-editor-modal/build-modifiers.cjs +91 -0
- package/build/components/media-editor-modal/build-modifiers.cjs.map +7 -0
- package/build/components/media-editor-modal/index.cjs +497 -0
- package/build/components/media-editor-modal/index.cjs.map +7 -0
- package/build/components/media-editor-toolbar/index.cjs +146 -0
- package/build/components/media-editor-toolbar/index.cjs.map +7 -0
- package/build/image-editor/core/camera.cjs +194 -0
- package/build/image-editor/core/camera.cjs.map +7 -0
- package/build/image-editor/core/constants.cjs +81 -0
- package/build/image-editor/core/constants.cjs.map +7 -0
- package/build/image-editor/core/containment.cjs +245 -0
- package/build/image-editor/core/containment.cjs.map +7 -0
- package/build/image-editor/core/export/canvas-renderer.cjs +151 -0
- package/build/image-editor/core/export/canvas-renderer.cjs.map +7 -0
- package/build/image-editor/core/index.cjs +50 -0
- package/build/image-editor/core/index.cjs.map +7 -0
- package/build/image-editor/core/interaction-controller.cjs +608 -0
- package/build/image-editor/core/interaction-controller.cjs.map +7 -0
- package/build/image-editor/core/math/rotation.cjs +41 -0
- package/build/image-editor/core/math/rotation.cjs.map +7 -0
- package/build/image-editor/core/source-region.cjs +95 -0
- package/build/image-editor/core/source-region.cjs.map +7 -0
- package/build/image-editor/core/state.cjs +269 -0
- package/build/image-editor/core/state.cjs.map +7 -0
- package/build/image-editor/core/stencil-math.cjs +197 -0
- package/build/image-editor/core/stencil-math.cjs.map +7 -0
- package/build/image-editor/core/transform-style.cjs +46 -0
- package/build/image-editor/core/transform-style.cjs.map +7 -0
- package/build/image-editor/core/transforms/pipeline.cjs +43 -0
- package/build/image-editor/core/transforms/pipeline.cjs.map +7 -0
- package/build/image-editor/core/types.cjs +19 -0
- package/build/image-editor/core/types.cjs.map +7 -0
- package/build/image-editor/index.cjs +57 -0
- package/build/image-editor/index.cjs.map +7 -0
- package/build/image-editor/react/components/cropper-provider.cjs +50 -0
- package/build/image-editor/react/components/cropper-provider.cjs.map +7 -0
- package/build/image-editor/react/components/cropper.cjs +365 -0
- package/build/image-editor/react/components/cropper.cjs.map +7 -0
- package/build/image-editor/react/components/index.cjs +36 -0
- package/build/image-editor/react/components/index.cjs.map +7 -0
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs +58 -0
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +7 -0
- package/build/image-editor/react/components/overlays/grid-overlay.cjs +91 -0
- package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +7 -0
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +351 -0
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +7 -0
- package/build/image-editor/react/hooks/index.cjs +31 -0
- package/build/image-editor/react/hooks/index.cjs.map +7 -0
- package/build/image-editor/react/hooks/use-aria-announcer.cjs +68 -0
- package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +7 -0
- package/build/image-editor/react/hooks/use-cropper-state.cjs +158 -0
- package/build/image-editor/react/hooks/use-cropper-state.cjs.map +7 -0
- package/build/image-editor/react/hooks/use-interaction.cjs +161 -0
- package/build/image-editor/react/hooks/use-interaction.cjs.map +7 -0
- package/build/image-editor/react/hooks/use-transform-style.cjs +38 -0
- package/build/image-editor/react/hooks/use-transform-style.cjs.map +7 -0
- package/build/index.cjs +5 -2
- package/build/index.cjs.map +2 -2
- package/build/lock-unlock.cjs +37 -0
- package/build/lock-unlock.cjs.map +7 -0
- package/build/private-apis.cjs +38 -0
- package/build/private-apis.cjs.map +7 -0
- package/build/store/actions.cjs +45 -0
- package/build/store/actions.cjs.map +7 -0
- package/build/store/constants.cjs +31 -0
- package/build/store/constants.cjs.map +7 -0
- package/build/store/index.cjs +51 -0
- package/build/store/index.cjs.map +7 -0
- package/build/store/reducer.cjs +51 -0
- package/build/store/reducer.cjs.map +7 -0
- package/build/store/selectors.cjs +43 -0
- package/build/store/selectors.cjs.map +7 -0
- package/build-module/components/media-editor-canvas/index.mjs +33 -0
- package/build-module/components/media-editor-canvas/index.mjs.map +7 -0
- package/build-module/components/media-editor-crop-panel/index.mjs +100 -0
- package/build-module/components/media-editor-crop-panel/index.mjs.map +7 -0
- package/build-module/components/media-editor-modal/build-modifiers.mjs +66 -0
- package/build-module/components/media-editor-modal/build-modifiers.mjs.map +7 -0
- package/build-module/components/media-editor-modal/index.mjs +483 -0
- package/build-module/components/media-editor-modal/index.mjs.map +7 -0
- package/build-module/components/media-editor-toolbar/index.mjs +130 -0
- package/build-module/components/media-editor-toolbar/index.mjs.map +7 -0
- package/build-module/image-editor/core/camera.mjs +163 -0
- package/build-module/image-editor/core/camera.mjs.map +7 -0
- package/build-module/image-editor/core/constants.mjs +51 -0
- package/build-module/image-editor/core/constants.mjs.map +7 -0
- package/build-module/image-editor/core/containment.mjs +218 -0
- package/build-module/image-editor/core/containment.mjs.map +7 -0
- package/build-module/image-editor/core/export/canvas-renderer.mjs +120 -0
- package/build-module/image-editor/core/export/canvas-renderer.mjs.map +7 -0
- package/build-module/image-editor/core/index.mjs +24 -0
- package/build-module/image-editor/core/index.mjs.map +7 -0
- package/build-module/image-editor/core/interaction-controller.mjs +583 -0
- package/build-module/image-editor/core/interaction-controller.mjs.map +7 -0
- package/build-module/image-editor/core/math/rotation.mjs +15 -0
- package/build-module/image-editor/core/math/rotation.mjs.map +7 -0
- package/build-module/image-editor/core/source-region.mjs +69 -0
- package/build-module/image-editor/core/source-region.mjs.map +7 -0
- package/build-module/image-editor/core/state.mjs +242 -0
- package/build-module/image-editor/core/state.mjs.map +7 -0
- package/build-module/image-editor/core/stencil-math.mjs +169 -0
- package/build-module/image-editor/core/stencil-math.mjs.map +7 -0
- package/build-module/image-editor/core/transform-style.mjs +21 -0
- package/build-module/image-editor/core/transform-style.mjs.map +7 -0
- package/build-module/image-editor/core/transforms/pipeline.mjs +17 -0
- package/build-module/image-editor/core/transforms/pipeline.mjs.map +7 -0
- package/build-module/image-editor/core/types.mjs +1 -0
- package/build-module/image-editor/core/types.mjs.map +7 -0
- package/build-module/image-editor/index.mjs +30 -0
- package/build-module/image-editor/index.mjs.map +7 -0
- package/build-module/image-editor/react/components/cropper-provider.mjs +26 -0
- package/build-module/image-editor/react/components/cropper-provider.mjs.map +7 -0
- package/build-module/image-editor/react/components/cropper.mjs +337 -0
- package/build-module/image-editor/react/components/cropper.mjs.map +7 -0
- package/build-module/image-editor/react/components/index.mjs +9 -0
- package/build-module/image-editor/react/components/index.mjs.map +7 -0
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +33 -0
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +7 -0
- package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +66 -0
- package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +7 -0
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +330 -0
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +7 -0
- package/build-module/image-editor/react/hooks/index.mjs +6 -0
- package/build-module/image-editor/react/hooks/index.mjs.map +7 -0
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +43 -0
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +7 -0
- package/build-module/image-editor/react/hooks/use-cropper-state.mjs +137 -0
- package/build-module/image-editor/react/hooks/use-cropper-state.mjs.map +7 -0
- package/build-module/image-editor/react/hooks/use-interaction.mjs +138 -0
- package/build-module/image-editor/react/hooks/use-interaction.mjs.map +7 -0
- package/build-module/image-editor/react/hooks/use-transform-style.mjs +13 -0
- package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +7 -0
- package/build-module/index.mjs +3 -1
- package/build-module/index.mjs.map +2 -2
- package/build-module/lock-unlock.mjs +11 -0
- package/build-module/lock-unlock.mjs.map +7 -0
- package/build-module/private-apis.mjs +13 -0
- package/build-module/private-apis.mjs.map +7 -0
- package/build-module/store/actions.mjs +19 -0
- package/build-module/store/actions.mjs.map +7 -0
- package/build-module/store/constants.mjs +6 -0
- package/build-module/store/constants.mjs.map +7 -0
- package/build-module/store/index.mjs +16 -0
- package/build-module/store/index.mjs.map +7 -0
- package/build-module/store/reducer.mjs +26 -0
- package/build-module/store/reducer.mjs.map +7 -0
- package/build-module/store/selectors.mjs +16 -0
- package/build-module/store/selectors.mjs.map +7 -0
- package/build-style/style-rtl.css +315 -0
- package/build-style/style.css +315 -0
- package/build-types/components/media-editor-canvas/index.d.ts +22 -0
- package/build-types/components/media-editor-canvas/index.d.ts.map +1 -0
- package/build-types/components/media-editor-crop-panel/index.d.ts +45 -0
- package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -0
- package/build-types/components/media-editor-modal/build-modifiers.d.ts +83 -0
- package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +1 -0
- package/build-types/components/media-editor-modal/index.d.ts +20 -0
- package/build-types/components/media-editor-modal/index.d.ts.map +1 -0
- package/build-types/components/media-editor-toolbar/index.d.ts +21 -0
- package/build-types/components/media-editor-toolbar/index.d.ts.map +1 -0
- package/build-types/image-editor/core/camera.d.ts +107 -0
- package/build-types/image-editor/core/camera.d.ts.map +1 -0
- package/build-types/image-editor/core/constants.d.ts +46 -0
- package/build-types/image-editor/core/constants.d.ts.map +1 -0
- package/build-types/image-editor/core/containment.d.ts +61 -0
- package/build-types/image-editor/core/containment.d.ts.map +1 -0
- package/build-types/image-editor/core/export/canvas-renderer.d.ts +106 -0
- package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +1 -0
- package/build-types/image-editor/core/index.d.ts +8 -0
- package/build-types/image-editor/core/index.d.ts.map +1 -0
- package/build-types/image-editor/core/interaction-controller.d.ts +178 -0
- package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -0
- package/build-types/image-editor/core/math/rotation.d.ts +18 -0
- package/build-types/image-editor/core/math/rotation.d.ts.map +1 -0
- package/build-types/image-editor/core/source-region.d.ts +75 -0
- package/build-types/image-editor/core/source-region.d.ts.map +1 -0
- package/build-types/image-editor/core/state.d.ts +42 -0
- package/build-types/image-editor/core/state.d.ts.map +1 -0
- package/build-types/image-editor/core/stencil-math.d.ts +79 -0
- package/build-types/image-editor/core/stencil-math.d.ts.map +1 -0
- package/build-types/image-editor/core/transform-style.d.ts +23 -0
- package/build-types/image-editor/core/transform-style.d.ts.map +1 -0
- package/build-types/image-editor/core/transforms/pipeline.d.ts +27 -0
- package/build-types/image-editor/core/transforms/pipeline.d.ts.map +1 -0
- package/build-types/image-editor/core/types.d.ts +211 -0
- package/build-types/image-editor/core/types.d.ts.map +1 -0
- package/build-types/image-editor/index.d.ts +16 -0
- package/build-types/image-editor/index.d.ts.map +1 -0
- package/build-types/image-editor/react/components/cropper-provider.d.ts +37 -0
- package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -0
- package/build-types/image-editor/react/components/cropper.d.ts +59 -0
- package/build-types/image-editor/react/components/cropper.d.ts.map +1 -0
- package/build-types/image-editor/react/components/index.d.ts +4 -0
- package/build-types/image-editor/react/components/index.d.ts.map +1 -0
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +30 -0
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +1 -0
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +30 -0
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +1 -0
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +32 -0
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -0
- package/build-types/image-editor/react/hooks/index.d.ts +3 -0
- package/build-types/image-editor/react/hooks/index.d.ts.map +1 -0
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +16 -0
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -0
- package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +68 -0
- package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +1 -0
- package/build-types/image-editor/react/hooks/use-interaction.d.ts +60 -0
- package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -0
- package/build-types/image-editor/react/hooks/use-transform-style.d.ts +16 -0
- package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +1 -0
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts +16 -0
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -0
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/private-apis.d.ts +2 -0
- package/build-types/private-apis.d.ts.map +1 -0
- package/build-types/store/actions.d.ts +27 -0
- package/build-types/store/actions.d.ts.map +1 -0
- package/build-types/store/constants.d.ts +2 -0
- package/build-types/store/constants.d.ts.map +1 -0
- package/build-types/store/index.d.ts +4 -0
- package/build-types/store/index.d.ts.map +1 -0
- package/build-types/store/reducer.d.ts +23 -0
- package/build-types/store/reducer.d.ts.map +1 -0
- package/build-types/store/selectors.d.ts +8 -0
- package/build-types/store/selectors.d.ts.map +1 -0
- package/package.json +21 -7
- package/src/components/media-editor-canvas/index.tsx +56 -0
- package/src/components/media-editor-canvas/style.scss +9 -0
- package/src/components/media-editor-crop-panel/index.tsx +143 -0
- package/src/components/media-editor-modal/build-modifiers.ts +164 -0
- package/src/components/media-editor-modal/index.tsx +639 -0
- package/src/components/media-editor-modal/style.scss +139 -0
- package/src/components/media-editor-modal/test/build-modifiers.test.ts +343 -0
- package/src/components/media-editor-toolbar/index.tsx +150 -0
- package/src/components/media-editor-toolbar/style.scss +21 -0
- package/src/image-editor/README.md +162 -0
- package/src/image-editor/core/camera.ts +352 -0
- package/src/image-editor/core/constants.ts +93 -0
- package/src/image-editor/core/containment.ts +435 -0
- package/src/image-editor/core/export/canvas-renderer.ts +253 -0
- package/src/image-editor/core/export/test/canvas-renderer.ts +813 -0
- package/src/image-editor/core/index.ts +35 -0
- package/src/image-editor/core/interaction-controller.ts +889 -0
- package/src/image-editor/core/math/rotation.ts +26 -0
- package/src/image-editor/core/source-region.ts +166 -0
- package/src/image-editor/core/state.ts +428 -0
- package/src/image-editor/core/stencil-math.ts +330 -0
- package/src/image-editor/core/test/camera.ts +593 -0
- package/src/image-editor/core/test/interaction-controller.ts +996 -0
- package/src/image-editor/core/test/preview-export-parity.ts +242 -0
- package/src/image-editor/core/test/render-camera-bridge.ts +348 -0
- package/src/image-editor/core/test/state.ts +762 -0
- package/src/image-editor/core/test/stencil-math.ts +321 -0
- package/src/image-editor/core/transform-style.ts +44 -0
- package/src/image-editor/core/transforms/pipeline.ts +43 -0
- package/src/image-editor/core/transforms/test/pipeline.ts +269 -0
- package/src/image-editor/core/types.ts +177 -0
- package/src/image-editor/docs/architecture.md +96 -0
- package/src/image-editor/docs/recipes.md +720 -0
- package/src/image-editor/docs/roadmap.md +66 -0
- package/src/image-editor/index.ts +43 -0
- package/src/image-editor/react/components/cropper-provider.tsx +73 -0
- package/src/image-editor/react/components/cropper.scss +195 -0
- package/src/image-editor/react/components/cropper.tsx +534 -0
- package/src/image-editor/react/components/index.ts +3 -0
- package/src/image-editor/react/components/overlays/dimming-overlay.tsx +57 -0
- package/src/image-editor/react/components/overlays/grid-overlay.tsx +80 -0
- package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +513 -0
- package/src/image-editor/react/components/stencils/test/rectangle-stencil.tsx +265 -0
- package/src/image-editor/react/components/test/cropper.tsx +140 -0
- package/src/image-editor/react/hooks/index.ts +2 -0
- package/src/image-editor/react/hooks/test/use-cropper-state.ts +913 -0
- package/src/image-editor/react/hooks/test/use-interaction.ts +218 -0
- package/src/image-editor/react/hooks/test/use-transform-style.ts +146 -0
- package/src/image-editor/react/hooks/use-aria-announcer.ts +64 -0
- package/src/image-editor/react/hooks/use-cropper-state.ts +238 -0
- package/src/image-editor/react/hooks/use-interaction.ts +223 -0
- package/src/image-editor/react/hooks/use-transform-style.ts +30 -0
- package/src/image-editor/stories/rectangle-crop.story.tsx +1085 -0
- package/src/image-editor/stories/style.css +94 -0
- package/src/image-editor/style.scss +1 -0
- package/src/index.ts +3 -0
- package/src/lock-unlock.ts +10 -0
- package/src/private-apis.ts +12 -0
- package/src/store/actions.ts +33 -0
- package/src/store/constants.ts +1 -0
- package/src/store/index.ts +20 -0
- package/src/store/reducer.ts +48 -0
- package/src/store/selectors.ts +16 -0
- package/src/store/test/reducer.ts +57 -0
- package/src/style.scss +4 -0
- package/tsconfig.json +10 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
.image-editor-story__container {
|
|
2
|
+
width: 100%;
|
|
3
|
+
max-width: 600px;
|
|
4
|
+
aspect-ratio: 3 / 2;
|
|
5
|
+
border: 1px solid #ccc;
|
|
6
|
+
position: relative;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.image-editor-story__resizable {
|
|
10
|
+
width: 600px;
|
|
11
|
+
height: 400px;
|
|
12
|
+
max-width: 100%;
|
|
13
|
+
min-width: 200px;
|
|
14
|
+
min-height: 200px;
|
|
15
|
+
border: 1px solid #ccc;
|
|
16
|
+
resize: both;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
position: relative;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.image-editor-story__toolbar {
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
gap: 12px;
|
|
25
|
+
padding: 8px;
|
|
26
|
+
margin-bottom: 12px;
|
|
27
|
+
border: 1px solid #e0e0e0;
|
|
28
|
+
border-radius: 4px;
|
|
29
|
+
background: #fafafa;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.image-editor-story__sliders {
|
|
33
|
+
display: grid;
|
|
34
|
+
grid-template-columns: 1fr 1fr;
|
|
35
|
+
gap: 16px;
|
|
36
|
+
padding: 0 4px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.image-editor-story__hidden-file {
|
|
40
|
+
display: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.image-editor-story__json {
|
|
44
|
+
width: 100%;
|
|
45
|
+
min-height: 80px;
|
|
46
|
+
font-family: monospace;
|
|
47
|
+
font-size: 12px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.image-editor-story__state {
|
|
51
|
+
font-family: monospace;
|
|
52
|
+
font-size: 11px;
|
|
53
|
+
background: #f5f5f5;
|
|
54
|
+
padding: 8px;
|
|
55
|
+
border-radius: 4px;
|
|
56
|
+
white-space: pre-wrap;
|
|
57
|
+
max-height: 200px;
|
|
58
|
+
overflow: auto;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.image-editor-story__vertex-count {
|
|
62
|
+
font-variant-numeric: tabular-nums;
|
|
63
|
+
min-width: 120px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.image-editor-story__instructions {
|
|
67
|
+
background: #f9f9f9;
|
|
68
|
+
border: 1px solid #e0e0e0;
|
|
69
|
+
border-radius: 4px;
|
|
70
|
+
padding: 12px;
|
|
71
|
+
font-size: 13px;
|
|
72
|
+
line-height: 1.5;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.image-editor-story__instructions p {
|
|
76
|
+
margin: 0 0 4px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.image-editor-story__instructions p:last-child {
|
|
80
|
+
margin-bottom: 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.image-editor-story__export-preview {
|
|
84
|
+
margin-bottom: 16px;
|
|
85
|
+
max-width: 200px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.image-editor-story__export-image {
|
|
89
|
+
display: block;
|
|
90
|
+
max-width: 100%;
|
|
91
|
+
border: 1px solid #ccc;
|
|
92
|
+
border-radius: 4px;
|
|
93
|
+
background: repeating-conic-gradient(#e0e0e0 0% 25%, transparent 0% 50%) 50% / 16px 16px;
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@use "./react/components/cropper.scss" as *;
|
package/src/index.ts
CHANGED
|
@@ -13,3 +13,6 @@ export type { MediaFormProps } from './components/media-form';
|
|
|
13
13
|
|
|
14
14
|
// Re-export commonly used dataviews types for convenience
|
|
15
15
|
export type { Field, Form } from '@wordpress/dataviews';
|
|
16
|
+
|
|
17
|
+
// Private APIs (experimental — not for use outside of core packages).
|
|
18
|
+
export { privateApis } from './private-apis';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
|
|
5
|
+
|
|
6
|
+
export const { lock, unlock } =
|
|
7
|
+
__dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
|
8
|
+
'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',
|
|
9
|
+
'@wordpress/media-editor'
|
|
10
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { lock } from './lock-unlock';
|
|
5
|
+
import { store } from './store';
|
|
6
|
+
import { MediaEditorModal } from './components/media-editor-modal';
|
|
7
|
+
|
|
8
|
+
export const privateApis = {};
|
|
9
|
+
lock( privateApis, {
|
|
10
|
+
store,
|
|
11
|
+
MediaEditorModal,
|
|
12
|
+
} );
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape passed to `onUpdate` after a successful save. Deliberately normalized
|
|
3
|
+
* and minimal: `url` instead of REST's `source_url`, so consumers can drop
|
|
4
|
+
* it straight into block attributes (matches the legacy `ImageEditor`'s
|
|
5
|
+
* `onSaveImage` shape at
|
|
6
|
+
* `packages/block-editor/src/components/image-editor/use-save-image.js`).
|
|
7
|
+
* Keeping this decoupled from the REST field names also leaves room to reuse
|
|
8
|
+
* the modal outside a WordPress REST context (e.g. native/Electron hosts).
|
|
9
|
+
*/
|
|
10
|
+
export interface MediaEditorModalUpdate {
|
|
11
|
+
id: number;
|
|
12
|
+
url?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface OpenMediaEditorModalArgs {
|
|
16
|
+
id: number;
|
|
17
|
+
onUpdate?: ( updated: MediaEditorModalUpdate ) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function openMediaEditorModal( {
|
|
21
|
+
id,
|
|
22
|
+
onUpdate,
|
|
23
|
+
}: OpenMediaEditorModalArgs ) {
|
|
24
|
+
return {
|
|
25
|
+
type: 'OPEN_MEDIA_EDITOR_MODAL' as const,
|
|
26
|
+
id,
|
|
27
|
+
onUpdate: onUpdate ?? null,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function closeMediaEditorModal() {
|
|
32
|
+
return { type: 'CLOSE_MEDIA_EDITOR_MODAL' as const };
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const STORE_NAME = 'core/media-editor';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createReduxStore, register } from '@wordpress/data';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import reducer from './reducer';
|
|
10
|
+
import * as actions from './actions';
|
|
11
|
+
import * as selectors from './selectors';
|
|
12
|
+
import { STORE_NAME } from './constants';
|
|
13
|
+
|
|
14
|
+
export const store = createReduxStore( STORE_NAME, {
|
|
15
|
+
reducer,
|
|
16
|
+
actions,
|
|
17
|
+
selectors,
|
|
18
|
+
} );
|
|
19
|
+
|
|
20
|
+
register( store );
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { MediaEditorModalUpdate } from './actions';
|
|
5
|
+
|
|
6
|
+
type OnUpdateCallback = ( updated: MediaEditorModalUpdate ) => void;
|
|
7
|
+
|
|
8
|
+
export interface State {
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
id: number | null;
|
|
11
|
+
onUpdate: OnUpdateCallback | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const DEFAULT_STATE: State = {
|
|
15
|
+
isOpen: false,
|
|
16
|
+
id: null,
|
|
17
|
+
onUpdate: null,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type Action =
|
|
21
|
+
| {
|
|
22
|
+
type: 'OPEN_MEDIA_EDITOR_MODAL';
|
|
23
|
+
id: number;
|
|
24
|
+
onUpdate: OnUpdateCallback | null;
|
|
25
|
+
}
|
|
26
|
+
| { type: 'CLOSE_MEDIA_EDITOR_MODAL' };
|
|
27
|
+
|
|
28
|
+
export default function reducer(
|
|
29
|
+
state: State = DEFAULT_STATE,
|
|
30
|
+
action: Action | { type: string }
|
|
31
|
+
): State {
|
|
32
|
+
switch ( action.type ) {
|
|
33
|
+
case 'OPEN_MEDIA_EDITOR_MODAL': {
|
|
34
|
+
const { id, onUpdate } = action as Extract<
|
|
35
|
+
Action,
|
|
36
|
+
{ type: 'OPEN_MEDIA_EDITOR_MODAL' }
|
|
37
|
+
>;
|
|
38
|
+
return {
|
|
39
|
+
isOpen: true,
|
|
40
|
+
id,
|
|
41
|
+
onUpdate,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
case 'CLOSE_MEDIA_EDITOR_MODAL':
|
|
45
|
+
return DEFAULT_STATE;
|
|
46
|
+
}
|
|
47
|
+
return state;
|
|
48
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { State } from './reducer';
|
|
5
|
+
|
|
6
|
+
export function isOpen( state: State ): boolean {
|
|
7
|
+
return state.isOpen;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getId( state: State ): number | null {
|
|
11
|
+
return state.id;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function getOnUpdate( state: State ) {
|
|
15
|
+
return state.onUpdate;
|
|
16
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import reducer, { DEFAULT_STATE } from '../reducer';
|
|
5
|
+
|
|
6
|
+
describe( 'core/media-editor reducer', () => {
|
|
7
|
+
it( 'returns the default state for an unknown action', () => {
|
|
8
|
+
const state = reducer( undefined, { type: '@@INIT' } );
|
|
9
|
+
expect( state ).toEqual( DEFAULT_STATE );
|
|
10
|
+
} );
|
|
11
|
+
|
|
12
|
+
it( 'opens the modal with id and onUpdate', () => {
|
|
13
|
+
const onUpdate = jest.fn();
|
|
14
|
+
const state = reducer( undefined, {
|
|
15
|
+
type: 'OPEN_MEDIA_EDITOR_MODAL',
|
|
16
|
+
id: 42,
|
|
17
|
+
onUpdate,
|
|
18
|
+
} );
|
|
19
|
+
expect( state ).toEqual( {
|
|
20
|
+
isOpen: true,
|
|
21
|
+
id: 42,
|
|
22
|
+
onUpdate,
|
|
23
|
+
} );
|
|
24
|
+
} );
|
|
25
|
+
|
|
26
|
+
it( 'replaces state on a subsequent open (new onUpdate)', () => {
|
|
27
|
+
const firstOnUpdate = jest.fn();
|
|
28
|
+
const secondOnUpdate = jest.fn();
|
|
29
|
+
const first = reducer( undefined, {
|
|
30
|
+
type: 'OPEN_MEDIA_EDITOR_MODAL',
|
|
31
|
+
id: 42,
|
|
32
|
+
onUpdate: firstOnUpdate,
|
|
33
|
+
} );
|
|
34
|
+
const second = reducer( first, {
|
|
35
|
+
type: 'OPEN_MEDIA_EDITOR_MODAL',
|
|
36
|
+
id: 99,
|
|
37
|
+
onUpdate: secondOnUpdate,
|
|
38
|
+
} );
|
|
39
|
+
expect( second ).toEqual( {
|
|
40
|
+
isOpen: true,
|
|
41
|
+
id: 99,
|
|
42
|
+
onUpdate: secondOnUpdate,
|
|
43
|
+
} );
|
|
44
|
+
} );
|
|
45
|
+
|
|
46
|
+
it( 'clears state on close', () => {
|
|
47
|
+
const opened = reducer( undefined, {
|
|
48
|
+
type: 'OPEN_MEDIA_EDITOR_MODAL',
|
|
49
|
+
id: 42,
|
|
50
|
+
onUpdate: jest.fn(),
|
|
51
|
+
} );
|
|
52
|
+
const closed = reducer( opened, {
|
|
53
|
+
type: 'CLOSE_MEDIA_EDITOR_MODAL',
|
|
54
|
+
} );
|
|
55
|
+
expect( closed ).toEqual( DEFAULT_STATE );
|
|
56
|
+
} );
|
|
57
|
+
} );
|
package/src/style.scss
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
// Import component styles
|
|
2
2
|
@use "./components/media-preview/style.scss" as *;
|
|
3
|
+
@use "./image-editor/style.scss" as *;
|
|
4
|
+
@use "./components/media-editor-modal/style.scss" as *;
|
|
5
|
+
@use "./components/media-editor-canvas/style.scss" as *;
|
|
6
|
+
@use "./components/media-editor-toolbar/style.scss" as *;
|
package/tsconfig.json
CHANGED
|
@@ -2,12 +2,20 @@
|
|
|
2
2
|
"$schema": "https://json.schemastore.org/tsconfig.json",
|
|
3
3
|
"extends": "../../tsconfig.base.json",
|
|
4
4
|
"compilerOptions": {
|
|
5
|
-
"types": [ "gutenberg-env" ]
|
|
5
|
+
"types": [ "gutenberg-env", "style-imports" ],
|
|
6
|
+
"checkJs": false
|
|
6
7
|
},
|
|
7
8
|
"references": [
|
|
9
|
+
{ "path": "../api-fetch" },
|
|
8
10
|
{ "path": "../components" },
|
|
11
|
+
{ "path": "../core-data" },
|
|
12
|
+
{ "path": "../data" },
|
|
9
13
|
{ "path": "../dataviews" },
|
|
10
14
|
{ "path": "../element" },
|
|
11
|
-
{ "path": "../i18n" }
|
|
15
|
+
{ "path": "../i18n" },
|
|
16
|
+
{ "path": "../icons" },
|
|
17
|
+
{ "path": "../notices" },
|
|
18
|
+
{ "path": "../private-apis" },
|
|
19
|
+
{ "path": "../ui" }
|
|
12
20
|
]
|
|
13
21
|
}
|