@wordpress/media-editor 0.13.0 → 0.13.1-next.v.202607070741.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/index.cjs +38 -39
- package/build/components/media-editor/index.cjs.map +3 -3
- package/build/components/media-editor-crop-panel/index.cjs +0 -1
- package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
- package/build-module/components/media-editor/index.mjs +40 -43
- package/build-module/components/media-editor/index.mjs.map +2 -2
- package/build-module/components/media-editor-crop-panel/index.mjs +0 -1
- package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
- package/build-style/style-rtl.css +7 -1
- package/build-style/style.css +7 -1
- package/build-types/components/media-editor/index.d.ts.map +1 -1
- package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -1
- package/package.json +20 -19
- package/src/components/media-editor/index.tsx +75 -74
- package/src/components/media-editor/style.scss +9 -10
- package/src/components/media-editor-crop-panel/index.tsx +0 -1
- package/src/image-editor/stories/rectangle-crop.story.tsx +0 -7
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/media-editor-crop-panel/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { SelectControl } from '@wordpress/components';\nimport { Stack, VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';\nimport MediaEditorImageControls from '../media-editor-image-controls';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\nexport interface MediaEditorCropPanelProps {\n\t/**\n\t * Selected aspect-ratio preset value as a string (so it round-trips\n\t * through `<SelectControl>`). `'0'` = free, `'-1'` = original, any\n\t * positive number = fixed ratio.\n\t */\n\taspectRatioValue: string;\n\t/** Setter for the aspect-ratio preset value. */\n\tonAspectRatioChange: ( value: string ) => void;\n\t/** Aspect-ratio presets to display in the selector. */\n\taspectRatioOptions: AspectRatioPreset[];\n\t/**\n\t * When `true`, render the rotate/flip/zoom image controls at the top of\n\t * the panel. Used on wide viewports where the footer no longer carries\n\t * them.\n\t */\n\tshowTransformControls?: boolean;\n}\n\n/**\n * Sidebar panel for crop controls. Renders the aspect-ratio selector, plus the\n * rotate/flip and zoom controls on wide viewports (these move to the footer\n * toolbar when the sidebar collapses).\n * @param props\n * @param props.aspectRatioValue\n * @param props.onAspectRatioChange\n * @param props.aspectRatioOptions\n * @param props.showTransformControls\n */\nexport default function MediaEditorCropPanel( {\n\taspectRatioValue,\n\tonAspectRatioChange,\n\taspectRatioOptions,\n\tshowTransformControls = false,\n}: MediaEditorCropPanelProps ) {\n\treturn (\n\t\t// Tag the whole panel as a crop-control region so the modal's\n\t\t// Cmd+Z handler doesn't mistake the SelectControl input for a\n\t\t// metadata field (which would suppress undo).\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"xl\"\n\t\t\t{ ...{ [ CROP_CONTROL_ATTR ]: true } }\n\t\t>\n\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t{ __( 'Crop options' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ showTransformControls && <MediaEditorImageControls withLabels /> }\n\t\t\t<SelectControl\n\t\t\t\
|
|
5
|
-
"mappings": ";AAGA,SAAS,qBAAqB;AAC9B,SAAS,OAAO,sBAAsB;AACtC,SAAS,UAAU;AAKnB,SAAS,yBAAyB;AAClC,OAAO,8BAA8B;AA0CnC,SAK0B,KAL1B;AAVa,SAAR,qBAAuC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AACzB,GAA+B;AAC9B;AAAA;AAAA;AAAA;AAAA,IAIC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,KAAI;AAAA,QACF,GAAG,EAAE,CAAE,iBAAkB,GAAG,KAAK;AAAA,QAEnC;AAAA,8BAAC,kBAAe,QAAS,oBAAC,QAAG,GAC1B,aAAI,cAAe,GACtB;AAAA,UACE,yBAAyB,oBAAC,4BAAyB,YAAU,MAAC;AAAA,UAChE;AAAA,YAAC;AAAA;AAAA,cACA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { SelectControl } from '@wordpress/components';\nimport { Stack, VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';\nimport MediaEditorImageControls from '../media-editor-image-controls';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\nexport interface MediaEditorCropPanelProps {\n\t/**\n\t * Selected aspect-ratio preset value as a string (so it round-trips\n\t * through `<SelectControl>`). `'0'` = free, `'-1'` = original, any\n\t * positive number = fixed ratio.\n\t */\n\taspectRatioValue: string;\n\t/** Setter for the aspect-ratio preset value. */\n\tonAspectRatioChange: ( value: string ) => void;\n\t/** Aspect-ratio presets to display in the selector. */\n\taspectRatioOptions: AspectRatioPreset[];\n\t/**\n\t * When `true`, render the rotate/flip/zoom image controls at the top of\n\t * the panel. Used on wide viewports where the footer no longer carries\n\t * them.\n\t */\n\tshowTransformControls?: boolean;\n}\n\n/**\n * Sidebar panel for crop controls. Renders the aspect-ratio selector, plus the\n * rotate/flip and zoom controls on wide viewports (these move to the footer\n * toolbar when the sidebar collapses).\n * @param props\n * @param props.aspectRatioValue\n * @param props.onAspectRatioChange\n * @param props.aspectRatioOptions\n * @param props.showTransformControls\n */\nexport default function MediaEditorCropPanel( {\n\taspectRatioValue,\n\tonAspectRatioChange,\n\taspectRatioOptions,\n\tshowTransformControls = false,\n}: MediaEditorCropPanelProps ) {\n\treturn (\n\t\t// Tag the whole panel as a crop-control region so the modal's\n\t\t// Cmd+Z handler doesn't mistake the SelectControl input for a\n\t\t// metadata field (which would suppress undo).\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"xl\"\n\t\t\t{ ...{ [ CROP_CONTROL_ATTR ]: true } }\n\t\t>\n\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t{ __( 'Crop options' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ showTransformControls && <MediaEditorImageControls withLabels /> }\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ onAspectRatioChange }\n\t\t\t\toptions={ aspectRatioOptions.map( ( preset ) => ( {\n\t\t\t\t\tlabel: preset.label,\n\t\t\t\t\tvalue: preset.value.toString(),\n\t\t\t\t} ) ) }\n\t\t\t/>\n\t\t</Stack>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,qBAAqB;AAC9B,SAAS,OAAO,sBAAsB;AACtC,SAAS,UAAU;AAKnB,SAAS,yBAAyB;AAClC,OAAO,8BAA8B;AA0CnC,SAK0B,KAL1B;AAVa,SAAR,qBAAuC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AACzB,GAA+B;AAC9B;AAAA;AAAA;AAAA;AAAA,IAIC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,KAAI;AAAA,QACF,GAAG,EAAE,CAAE,iBAAkB,GAAG,KAAK;AAAA,QAEnC;AAAA,8BAAC,kBAAe,QAAS,oBAAC,QAAG,GAC1B,aAAI,cAAe,GACtB;AAAA,UACE,yBAAyB,oBAAC,4BAAyB,YAAU,MAAC;AAAA,UAChE;AAAA,YAAC;AAAA;AAAA,cACA,OAAQ,GAAI,cAAe;AAAA,cAC3B,OAAQ;AAAA,cACR,UAAW;AAAA,cACX,SAAU,mBAAmB,IAAK,CAAE,YAAc;AAAA,gBACjD,OAAO,OAAO;AAAA,gBACd,OAAO,OAAO,MAAM,SAAS;AAAA,cAC9B,EAAI;AAAA;AAAA,UACL;AAAA;AAAA;AAAA,IACD;AAAA;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -342,6 +342,12 @@
|
|
|
342
342
|
/**
|
|
343
343
|
* Focus styles.
|
|
344
344
|
*/
|
|
345
|
+
/**
|
|
346
|
+
* Standard focus rings for the WordPress Design System.
|
|
347
|
+
*
|
|
348
|
+
* Apply `outset-ring__focus` inside the relevant pseudo-class at the call site,
|
|
349
|
+
* e.g. `&:focus { @include outset-ring__focus(); }`.
|
|
350
|
+
*/
|
|
345
351
|
/**
|
|
346
352
|
* Applies editor left position to the selector passed as argument
|
|
347
353
|
*/
|
|
@@ -458,7 +464,7 @@
|
|
|
458
464
|
}
|
|
459
465
|
@media (min-width: 600px) {
|
|
460
466
|
.media-editor .media-editor__panel {
|
|
461
|
-
padding:
|
|
467
|
+
padding: 24px 0 0 24px;
|
|
462
468
|
}
|
|
463
469
|
}
|
|
464
470
|
.media-editor .components-panel__header.media-editor__sidebar-header {
|
package/build-style/style.css
CHANGED
|
@@ -342,6 +342,12 @@
|
|
|
342
342
|
/**
|
|
343
343
|
* Focus styles.
|
|
344
344
|
*/
|
|
345
|
+
/**
|
|
346
|
+
* Standard focus rings for the WordPress Design System.
|
|
347
|
+
*
|
|
348
|
+
* Apply `outset-ring__focus` inside the relevant pseudo-class at the call site,
|
|
349
|
+
* e.g. `&:focus { @include outset-ring__focus(); }`.
|
|
350
|
+
*/
|
|
345
351
|
/**
|
|
346
352
|
* Applies editor left position to the selector passed as argument
|
|
347
353
|
*/
|
|
@@ -458,7 +464,7 @@
|
|
|
458
464
|
}
|
|
459
465
|
@media (min-width: 600px) {
|
|
460
466
|
.media-editor .media-editor__panel {
|
|
461
|
-
padding:
|
|
467
|
+
padding: 24px 24px 0 0;
|
|
462
468
|
}
|
|
463
469
|
}
|
|
464
470
|
.media-editor .components-panel__header.media-editor__sidebar-header {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor/index.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAQlD,OAAO,KAAK,EAAE,aAAa,IAAI,kBAAkB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAM5E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAStD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,OAAO,EAGN,KAAK,qBAAqB,EAC1B,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAerE,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,EAAE,SAAS,CAAC;IACzB,aAAa,EAAE,SAAS,CAAC;IACzB;;;;;;;;OAQG;IACH,YAAY,EAAE,MAAM,GAAG,QAAQ,CAAC;IAChC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,SAAS,EAAE,CAAE,KAAK,EAAE,kBAAkB,CAAE,WAAW,CAAE,KAAM,IAAI,CAAC;IAChE,yBAAyB,EAAE,OAAO,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAChC,MAAM,CAAC,EAAE,KAAK,CAAE,KAAK,CAAE,EAAE,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,CAAE,MAAM,EAAE,qBAAqB,KAAM,IAAI,CAAC;IACpD,WAAW,EAAE,CAAE,KAAK,EAAE,qBAAqB,KAAM,GAAG,CAAC,OAAO,CAAC;IAC7D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACtC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B;AAwmBD,wBAAgB,WAAW,CAAE,KAAK,EAAE,gBAAgB,+BAMnD;eAEc,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-crop-panel/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,mBAAmB,EAAE,CAAE,KAAK,EAAE,MAAM,KAAM,IAAI,CAAC;IAC/C,uDAAuD;IACvD,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;IACxC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAE,EAC7C,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,qBAA6B,EAC7B,EAAE,yBAAyB,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-crop-panel/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,mBAAmB,EAAE,CAAE,KAAK,EAAE,MAAM,KAAM,IAAI,CAAC;IAC/C,uDAAuD;IACvD,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;IACxC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAE,EAC7C,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,qBAA6B,EAC7B,EAAE,yBAAyB,+BAyB3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rectangle-crop.story.d.ts","sourceRoot":"","sources":["../../../src/image-editor/stories/rectangle-crop.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAwB5D;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAuBtD,OAAO,aAAa,CAAC;AA6ErB,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,OAAO,CAI/B,CAAC;eAEa,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAE,OAAO,OAAO,CAAE,CAAC;AAsBxC,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC;
|
|
1
|
+
{"version":3,"file":"rectangle-crop.story.d.ts","sourceRoot":"","sources":["../../../src/image-editor/stories/rectangle-crop.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAwB5D;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAuBtD,OAAO,aAAa,CAAC;AA6ErB,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,OAAO,CAI/B,CAAC;eAEa,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAE,OAAO,OAAO,CAAE,CAAC;AAsBxC,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC;AAyWF,eAAO,MAAM,YAAY,EAAE,KAE1B,CAAC;AA4hBF,eAAO,MAAM,KAAK,EAAE,KAEnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/media-editor",
|
|
3
|
-
"version": "0.13.0",
|
|
3
|
+
"version": "0.13.1-next.v.202607070741.0+a51d59513",
|
|
4
4
|
"description": "Media editor components for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -43,27 +43,28 @@
|
|
|
43
43
|
"build-module/store/index.mjs"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@wordpress/api-fetch": "^7.50.0",
|
|
47
|
-
"@wordpress/base-styles": "^10.
|
|
48
|
-
"@wordpress/components": "^
|
|
49
|
-
"@wordpress/compose": "^8.3.0",
|
|
50
|
-
"@wordpress/core-data": "^7.50.0",
|
|
51
|
-
"@wordpress/data": "^10.50.0",
|
|
52
|
-
"@wordpress/dataviews": "^17.1.0",
|
|
53
|
-
"@wordpress/date": "^5.50.0",
|
|
54
|
-
"@wordpress/element": "^8.2.0",
|
|
55
|
-
"@wordpress/i18n": "^6.23.0",
|
|
56
|
-
"@wordpress/icons": "^15.1.0",
|
|
57
|
-
"@wordpress/interface": "^9.35.0",
|
|
58
|
-
"@wordpress/keyboard-shortcuts": "^5.50.0",
|
|
59
|
-
"@wordpress/keycodes": "^4.50.0",
|
|
60
|
-
"@wordpress/notices": "^5.50.0",
|
|
61
|
-
"@wordpress/private-apis": "^1.50.0",
|
|
62
|
-
"@wordpress/ui": "^0.
|
|
46
|
+
"@wordpress/api-fetch": "^7.50.1-next.v.202607070741.0+a51d59513",
|
|
47
|
+
"@wordpress/base-styles": "^10.3.1-next.v.202607070741.0+a51d59513",
|
|
48
|
+
"@wordpress/components": "^37.0.1-next.v.202607070741.0+a51d59513",
|
|
49
|
+
"@wordpress/compose": "^8.3.1-next.v.202607070741.0+a51d59513",
|
|
50
|
+
"@wordpress/core-data": "^7.50.1-next.v.202607070741.0+a51d59513",
|
|
51
|
+
"@wordpress/data": "^10.50.1-next.v.202607070741.0+a51d59513",
|
|
52
|
+
"@wordpress/dataviews": "^17.1.2-next.v.202607070741.0+a51d59513",
|
|
53
|
+
"@wordpress/date": "^5.50.1-next.v.202607070741.0+a51d59513",
|
|
54
|
+
"@wordpress/element": "^8.2.1-next.v.202607070741.0+a51d59513",
|
|
55
|
+
"@wordpress/i18n": "^6.23.1-next.v.202607070741.0+a51d59513",
|
|
56
|
+
"@wordpress/icons": "^15.1.1-next.v.202607070741.0+a51d59513",
|
|
57
|
+
"@wordpress/interface": "^9.35.1-next.v.202607070741.0+a51d59513",
|
|
58
|
+
"@wordpress/keyboard-shortcuts": "^5.50.1-next.v.202607070741.0+a51d59513",
|
|
59
|
+
"@wordpress/keycodes": "^4.50.1-next.v.202607070741.0+a51d59513",
|
|
60
|
+
"@wordpress/notices": "^5.50.1-next.v.202607070741.0+a51d59513",
|
|
61
|
+
"@wordpress/private-apis": "^1.50.1-next.v.202607070741.0+a51d59513",
|
|
62
|
+
"@wordpress/ui": "^0.18.1-next.v.202607070741.0+a51d59513",
|
|
63
63
|
"clsx": "^2.1.1",
|
|
64
64
|
"gl-matrix": "^3.4.3"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
+
"@storybook/react-vite": "^10.4.3",
|
|
67
68
|
"@testing-library/dom": "^10.4.1",
|
|
68
69
|
"@testing-library/react": "^16.3.2",
|
|
69
70
|
"@testing-library/user-event": "^14.6.1"
|
|
@@ -80,5 +81,5 @@
|
|
|
80
81
|
"publishConfig": {
|
|
81
82
|
"access": "public"
|
|
82
83
|
},
|
|
83
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "f637726e370c8b23695ed9af82adbe171ad235d8"
|
|
84
85
|
}
|
|
@@ -6,16 +6,14 @@ import {
|
|
|
6
6
|
Flex,
|
|
7
7
|
Spinner,
|
|
8
8
|
__experimentalConfirmDialog as ConfirmDialog,
|
|
9
|
-
privateApis as componentsPrivateApis,
|
|
10
9
|
} from '@wordpress/components';
|
|
11
|
-
import { Stack } from '@wordpress/ui';
|
|
10
|
+
import { Stack, Tabs } from '@wordpress/ui';
|
|
12
11
|
import { useViewportMatch } from '@wordpress/compose';
|
|
13
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
14
13
|
import { store as coreStore } from '@wordpress/core-data';
|
|
15
14
|
import {
|
|
16
15
|
createPortal,
|
|
17
16
|
useCallback,
|
|
18
|
-
useContext,
|
|
19
17
|
useEffect,
|
|
20
18
|
useMemo,
|
|
21
19
|
useRef,
|
|
@@ -50,7 +48,6 @@ import MediaEditorFineRotation from '../media-editor-fine-rotation';
|
|
|
50
48
|
import MediaEditorImageControls from '../media-editor-image-controls';
|
|
51
49
|
import MediaEditorCropPanel from '../media-editor-crop-panel';
|
|
52
50
|
import MediaForm from '../media-form';
|
|
53
|
-
import { unlock } from '../../lock-unlock';
|
|
54
51
|
import { getMediaTypeFromMimeType } from '../../utils';
|
|
55
52
|
import { MediaEditorStateProvider, useMediaEditor } from '../../state';
|
|
56
53
|
import type { AspectRatioPreset } from '../../image-editor/core/constants';
|
|
@@ -72,8 +69,6 @@ const ATTACHMENT_EMBED_QUERY = { _embed: 'author,wp:attached-to' } as const;
|
|
|
72
69
|
|
|
73
70
|
const PLACEMENT_CONTROL_IDLE_MS = 300;
|
|
74
71
|
|
|
75
|
-
const { Tabs } = unlock( componentsPrivateApis );
|
|
76
|
-
|
|
77
72
|
interface EditorTab {
|
|
78
73
|
id: string;
|
|
79
74
|
title: string;
|
|
@@ -116,7 +111,10 @@ export interface MediaEditorProps {
|
|
|
116
111
|
}
|
|
117
112
|
|
|
118
113
|
function MediaEditorSidebar( { tabs }: { tabs: EditorTab[] } ) {
|
|
119
|
-
|
|
114
|
+
// The tab list and panels must share one `<Tabs.Root>`, but they render in
|
|
115
|
+
// separate `ComplementaryArea` regions (header vs body). A non-virtual Slot
|
|
116
|
+
// reconciles both inline at the Slot, so the `Root` is lifted to wrap this
|
|
117
|
+
// Fill and that Slot together — see `MediaEditorContent`.
|
|
120
118
|
return (
|
|
121
119
|
<ComplementaryArea
|
|
122
120
|
scope="media-editor"
|
|
@@ -129,28 +127,20 @@ function MediaEditorSidebar( { tabs }: { tabs: EditorTab[] } ) {
|
|
|
129
127
|
headerClassName="media-editor__sidebar-header"
|
|
130
128
|
closeLabel={ __( 'Close media panel' ) }
|
|
131
129
|
header={
|
|
132
|
-
<Tabs.
|
|
133
|
-
|
|
134
|
-
{
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
</Tabs.TabList>
|
|
140
|
-
</Tabs.Context.Provider>
|
|
130
|
+
<Tabs.List variant="minimal">
|
|
131
|
+
{ tabs.map( ( tab ) => (
|
|
132
|
+
<Tabs.Tab key={ tab.id } value={ tab.id }>
|
|
133
|
+
{ tab.title }
|
|
134
|
+
</Tabs.Tab>
|
|
135
|
+
) ) }
|
|
136
|
+
</Tabs.List>
|
|
141
137
|
}
|
|
142
138
|
>
|
|
143
|
-
|
|
144
|
-
{
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
focusable={ false }
|
|
149
|
-
>
|
|
150
|
-
{ tab.panel }
|
|
151
|
-
</Tabs.TabPanel>
|
|
152
|
-
) ) }
|
|
153
|
-
</Tabs.Context.Provider>
|
|
139
|
+
{ tabs.map( ( tab ) => (
|
|
140
|
+
<Tabs.Panel key={ tab.id } value={ tab.id } tabIndex={ -1 }>
|
|
141
|
+
{ tab.panel }
|
|
142
|
+
</Tabs.Panel>
|
|
143
|
+
) ) }
|
|
154
144
|
</ComplementaryArea>
|
|
155
145
|
);
|
|
156
146
|
}
|
|
@@ -501,6 +491,13 @@ function MediaEditorContent( {
|
|
|
501
491
|
isPanelLayout,
|
|
502
492
|
] );
|
|
503
493
|
|
|
494
|
+
// Control the active tab from state here so the selection survives the
|
|
495
|
+
// sidebar closing (which unmounts the `ComplementaryArea` Fill and its
|
|
496
|
+
// tabs). Fall back to the first tab until one is picked, so images open on
|
|
497
|
+
// Crop.
|
|
498
|
+
const [ selectedTabId, setSelectedTabId ] = useState< string >();
|
|
499
|
+
const activeTabId = selectedTabId ?? tabs[ 0 ]?.id;
|
|
500
|
+
|
|
504
501
|
const handleChange = ( updates: Partial< Media > ) => {
|
|
505
502
|
editEntityRecord( 'postType', 'attachment', id, updates );
|
|
506
503
|
};
|
|
@@ -581,58 +578,62 @@ function MediaEditorContent( {
|
|
|
581
578
|
onChange={ handleChange }
|
|
582
579
|
settings={ { fields } }
|
|
583
580
|
>
|
|
584
|
-
|
|
585
|
-
|
|
581
|
+
{ ! media ? (
|
|
582
|
+
<div className="media-editor">
|
|
586
583
|
<div className="media-editor__loading">
|
|
587
584
|
<Spinner />
|
|
588
585
|
</div>
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
</div>
|
|
586
|
+
</div>
|
|
587
|
+
) : (
|
|
588
|
+
<Tabs.Root
|
|
589
|
+
className="media-editor"
|
|
590
|
+
value={ activeTabId }
|
|
591
|
+
onValueChange={ ( value ) =>
|
|
592
|
+
setSelectedTabId( value as string )
|
|
593
|
+
}
|
|
594
|
+
>
|
|
595
|
+
<MediaEditorSidebar tabs={ tabs } />
|
|
596
|
+
<InterfaceSkeleton
|
|
597
|
+
className="media-editor__skeleton"
|
|
598
|
+
labels={ {
|
|
599
|
+
body: isImage
|
|
600
|
+
? __( 'Image editor' )
|
|
601
|
+
: __( 'Media preview' ),
|
|
602
|
+
sidebar: __( 'Media details' ),
|
|
603
|
+
} }
|
|
604
|
+
content={
|
|
605
|
+
<div className="media-editor__content">
|
|
606
|
+
<div className="media-editor__canvas-area">
|
|
607
|
+
{ isImage ? (
|
|
608
|
+
<MediaEditorCanvas
|
|
609
|
+
focusOnMount
|
|
610
|
+
isPlacementActive={
|
|
611
|
+
isPlacementActive
|
|
612
|
+
}
|
|
613
|
+
onGestureStart={
|
|
614
|
+
handleCanvasGestureStart
|
|
615
|
+
}
|
|
616
|
+
onGestureEnd={
|
|
617
|
+
handleCanvasGestureEnd
|
|
618
|
+
}
|
|
619
|
+
/>
|
|
620
|
+
) : (
|
|
621
|
+
<MediaPreview />
|
|
626
622
|
) }
|
|
627
623
|
</div>
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
624
|
+
{ isImage && (
|
|
625
|
+
<div className="media-editor__canvas-toolbar">
|
|
626
|
+
{ ruler }
|
|
627
|
+
</div>
|
|
628
|
+
) }
|
|
629
|
+
</div>
|
|
630
|
+
}
|
|
631
|
+
sidebar={
|
|
632
|
+
<ComplementaryArea.Slot scope="media-editor" />
|
|
633
|
+
}
|
|
634
|
+
/>
|
|
635
|
+
</Tabs.Root>
|
|
636
|
+
) }
|
|
636
637
|
<ConfirmDialog
|
|
637
638
|
isOpen={ isDiscardDialogOpen }
|
|
638
639
|
confirmButtonText={ __( 'Discard' ) }
|
|
@@ -30,15 +30,14 @@
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// The skeleton must always sit in the modal's flow (`top: auto`). The reset
|
|
33
|
-
// above sets that, but
|
|
34
|
-
// the
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
// the editor (and the fine-rotation ruler under the canvas) down
|
|
38
|
-
// full-screen modal that already overlays the admin bar.
|
|
39
|
-
// specificity that beats
|
|
40
|
-
// (`.media-editor` only ever renders inside `.media-editor-modal`)
|
|
41
|
-
// than on the experiment's class, which may change if it ever graduates.
|
|
33
|
+
// above sets that, but `@wordpress/interface` offsets every
|
|
34
|
+
// `.interface-interface-skeleton` below the admin bar in fullscreen mode via
|
|
35
|
+
// `.is-fullscreen-mode .interface-interface-skeleton { top: ... }`. That
|
|
36
|
+
// selector ties the reset's specificity, so source order lets it win and
|
|
37
|
+
// pushes the editor (and the fine-rotation ruler under the canvas) down
|
|
38
|
+
// inside our full-screen modal that already overlays the admin bar.
|
|
39
|
+
// Re-assert `top` at a specificity that beats it, anchored on the modal
|
|
40
|
+
// frame (`.media-editor` only ever renders inside `.media-editor-modal`).
|
|
42
41
|
.media-editor-modal & .interface-interface-skeleton.interface-interface-skeleton {
|
|
43
42
|
top: auto;
|
|
44
43
|
}
|
|
@@ -133,7 +132,7 @@
|
|
|
133
132
|
padding: $grid-unit-20;
|
|
134
133
|
|
|
135
134
|
@include break-small() {
|
|
136
|
-
padding: $grid-unit-
|
|
135
|
+
padding: $grid-unit-30 $grid-unit-30 0 0;
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
138
|
|
|
@@ -61,7 +61,6 @@ export default function MediaEditorCropPanel( {
|
|
|
61
61
|
</VisuallyHidden>
|
|
62
62
|
{ showTransformControls && <MediaEditorImageControls withLabels /> }
|
|
63
63
|
<SelectControl
|
|
64
|
-
__next40pxDefaultSize
|
|
65
64
|
label={ __( 'Aspect ratio' ) }
|
|
66
65
|
value={ aspectRatioValue }
|
|
67
66
|
onChange={ onAspectRatioChange }
|
|
@@ -395,7 +395,6 @@ const WithControlsComponent = () => {
|
|
|
395
395
|
</FlexItem>
|
|
396
396
|
<FlexItem>
|
|
397
397
|
<SelectControl
|
|
398
|
-
__next40pxDefaultSize
|
|
399
398
|
label="Aspect ratio"
|
|
400
399
|
hideLabelFromVision
|
|
401
400
|
value={ aspectRatioValue }
|
|
@@ -417,7 +416,6 @@ const WithControlsComponent = () => {
|
|
|
417
416
|
</FlexItem>
|
|
418
417
|
<FlexItem>
|
|
419
418
|
<SelectControl
|
|
420
|
-
__next40pxDefaultSize
|
|
421
419
|
label="Grid"
|
|
422
420
|
hideLabelFromVision
|
|
423
421
|
value={ gridMode }
|
|
@@ -450,7 +448,6 @@ const WithControlsComponent = () => {
|
|
|
450
448
|
</Flex>
|
|
451
449
|
<div className="image-editor-story__sliders">
|
|
452
450
|
<RangeControl
|
|
453
|
-
__next40pxDefaultSize
|
|
454
451
|
label="Fine rotation"
|
|
455
452
|
min={ -MAX_ROTATION_OFFSET }
|
|
456
453
|
max={ MAX_ROTATION_OFFSET }
|
|
@@ -459,7 +456,6 @@ const WithControlsComponent = () => {
|
|
|
459
456
|
onChange={ handleRotationSlider }
|
|
460
457
|
/>
|
|
461
458
|
<RangeControl
|
|
462
|
-
__next40pxDefaultSize
|
|
463
459
|
label="Zoom"
|
|
464
460
|
min={ getMinZoom( state ) }
|
|
465
461
|
max={ MAX_ZOOM }
|
|
@@ -831,7 +827,6 @@ const DebugComponent = () => {
|
|
|
831
827
|
</FlexItem>
|
|
832
828
|
<FlexItem>
|
|
833
829
|
<SelectControl
|
|
834
|
-
__next40pxDefaultSize
|
|
835
830
|
label="Format"
|
|
836
831
|
hideLabelFromVision
|
|
837
832
|
value={ exportFormat as 'image/jpeg' }
|
|
@@ -866,7 +861,6 @@ const DebugComponent = () => {
|
|
|
866
861
|
</Flex>
|
|
867
862
|
<div className="image-editor-story__sliders">
|
|
868
863
|
<RangeControl
|
|
869
|
-
__next40pxDefaultSize
|
|
870
864
|
label="Fine rotation"
|
|
871
865
|
min={ -MAX_ROTATION_OFFSET }
|
|
872
866
|
max={ MAX_ROTATION_OFFSET }
|
|
@@ -875,7 +869,6 @@ const DebugComponent = () => {
|
|
|
875
869
|
onChange={ handleRotationSlider }
|
|
876
870
|
/>
|
|
877
871
|
<RangeControl
|
|
878
|
-
__next40pxDefaultSize
|
|
879
872
|
label="Zoom"
|
|
880
873
|
min={ getMinZoom( state ) }
|
|
881
874
|
max={ MAX_ZOOM }
|