@wordpress/block-library 9.45.0 → 9.45.1-next.v.202605131032.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.
Files changed (84) hide show
  1. package/build/breadcrumbs/edit.cjs +1 -1
  2. package/build/breadcrumbs/edit.cjs.map +1 -1
  3. package/build/buttons/edit.cjs +0 -13
  4. package/build/buttons/edit.cjs.map +3 -3
  5. package/build/comment-reply-link/edit.cjs +2 -1
  6. package/build/comment-reply-link/edit.cjs.map +2 -2
  7. package/build/comments/edit/placeholder.cjs +2 -1
  8. package/build/comments/edit/placeholder.cjs.map +2 -2
  9. package/build/embed/transforms.cjs +24 -1
  10. package/build/embed/transforms.cjs.map +2 -2
  11. package/build/freeform/convert-to-blocks-button.cjs +2 -14
  12. package/build/freeform/convert-to-blocks-button.cjs.map +3 -3
  13. package/build/freeform/edit.cjs +43 -15
  14. package/build/freeform/edit.cjs.map +3 -3
  15. package/build/freeform/index.cjs +7 -1
  16. package/build/freeform/index.cjs.map +3 -3
  17. package/build/freeform/migration-notice.cjs +58 -0
  18. package/build/freeform/migration-notice.cjs.map +7 -0
  19. package/build/image/image.cjs +16 -52
  20. package/build/image/image.cjs.map +3 -3
  21. package/build/image/use-open-image-media-editor-modal.cjs +239 -0
  22. package/build/image/use-open-image-media-editor-modal.cjs.map +7 -0
  23. package/build/index.cjs +1 -5
  24. package/build/index.cjs.map +2 -2
  25. package/build/shortcode/transforms.cjs +27 -1
  26. package/build/shortcode/transforms.cjs.map +2 -2
  27. package/build/site-logo/edit.cjs +1 -0
  28. package/build/site-logo/edit.cjs.map +2 -2
  29. package/build/table/edit.cjs +2 -2
  30. package/build/table/edit.cjs.map +2 -2
  31. package/build-module/breadcrumbs/edit.mjs +1 -1
  32. package/build-module/breadcrumbs/edit.mjs.map +1 -1
  33. package/build-module/buttons/edit.mjs +0 -13
  34. package/build-module/buttons/edit.mjs.map +2 -2
  35. package/build-module/comment-reply-link/edit.mjs +3 -2
  36. package/build-module/comment-reply-link/edit.mjs.map +2 -2
  37. package/build-module/comments/edit/placeholder.mjs +3 -2
  38. package/build-module/comments/edit/placeholder.mjs.map +2 -2
  39. package/build-module/embed/transforms.mjs +24 -1
  40. package/build-module/embed/transforms.mjs.map +2 -2
  41. package/build-module/freeform/convert-to-blocks-button.mjs +3 -15
  42. package/build-module/freeform/convert-to-blocks-button.mjs.map +2 -2
  43. package/build-module/freeform/edit.mjs +44 -16
  44. package/build-module/freeform/edit.mjs.map +2 -2
  45. package/build-module/freeform/index.mjs +7 -1
  46. package/build-module/freeform/index.mjs.map +2 -2
  47. package/build-module/freeform/migration-notice.mjs +37 -0
  48. package/build-module/freeform/migration-notice.mjs.map +7 -0
  49. package/build-module/image/image.mjs +16 -52
  50. package/build-module/image/image.mjs.map +3 -3
  51. package/build-module/image/use-open-image-media-editor-modal.mjs +215 -0
  52. package/build-module/image/use-open-image-media-editor-modal.mjs.map +7 -0
  53. package/build-module/index.mjs +1 -5
  54. package/build-module/index.mjs.map +2 -2
  55. package/build-module/shortcode/transforms.mjs +27 -1
  56. package/build-module/shortcode/transforms.mjs.map +2 -2
  57. package/build-module/site-logo/edit.mjs +1 -0
  58. package/build-module/site-logo/edit.mjs.map +2 -2
  59. package/build-module/table/edit.mjs +3 -3
  60. package/build-module/table/edit.mjs.map +2 -2
  61. package/build-types/table-of-contents/list.d.ts +1 -1
  62. package/build-types/table-of-contents/list.d.ts.map +1 -1
  63. package/package.json +41 -40
  64. package/src/breadcrumbs/edit.js +1 -1
  65. package/src/buttons/edit.js +0 -13
  66. package/src/comment-reply-link/edit.js +5 -2
  67. package/src/comments/edit/placeholder.js +5 -2
  68. package/src/cover/editor.scss +2 -2
  69. package/src/cover/style.scss +10 -6
  70. package/src/embed/transforms.js +30 -4
  71. package/src/freeform/convert-to-blocks-button.js +3 -18
  72. package/src/freeform/edit.js +40 -7
  73. package/src/freeform/index.js +9 -1
  74. package/src/freeform/migration-notice.js +51 -0
  75. package/src/image/image.js +14 -63
  76. package/src/image/test/use-open-image-media-editor-modal.js +791 -0
  77. package/src/image/use-open-image-media-editor-modal.js +337 -0
  78. package/src/index.js +3 -16
  79. package/src/navigation/index.php +11 -1
  80. package/src/query/editor.scss +1 -2
  81. package/src/shortcode/transforms.js +37 -0
  82. package/src/site-logo/edit.js +5 -0
  83. package/src/table/edit.js +3 -3
  84. package/src/template-part/editor.scss +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/embed/transforms.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport {\n\tfindMoreSuitableBlock,\n\trewriteXToTwitter,\n\tremoveAspectRatioClasses,\n} from './util';\n\nconst { name: EMBED_BLOCK } = metadata;\n\n/**\n * Default transforms for generic embeds.\n */\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tisMatch: ( node ) =>\n\t\t\t\tnode.nodeName === 'P' &&\n\t\t\t\t/^\\s*(https?:\\/\\/\\S+)\\s*$/i.test( node.textContent ) &&\n\t\t\t\tnode.textContent?.match( /https/gi )?.length === 1,\n\t\t\ttransform: ( node ) => {\n\t\t\t\tconst url = rewriteXToTwitter( node.textContent.trim() );\n\t\t\t\treturn createBlock( EMBED_BLOCK, {\n\t\t\t\t\turl,\n\t\t\t\t\t...findMoreSuitableBlock( url )?.attributes,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\tisMatch: ( { url } ) => !! url,\n\t\t\ttransform: ( { url, caption, className } ) => {\n\t\t\t\tlet value = `<a href=\"${ url }\">${ url }</a>`;\n\t\t\t\tif ( caption?.trim() ) {\n\t\t\t\t\tvalue += `<br />${ caption }`;\n\t\t\t\t}\n\t\t\t\treturn createBlock( 'core/paragraph', {\n\t\t\t\t\tcontent: value,\n\t\t\t\t\tclassName: removeAspectRatioClasses( className ),\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],
5
- "mappings": ";AAGA,SAAS,mBAAmB;AAK5B,OAAO,cAAc;AACrB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,IAAM,EAAE,MAAM,YAAY,IAAI;AAK9B,IAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA,MACN,SAAS,CAAE,SACV,KAAK,aAAa,OAClB,4BAA4B,KAAM,KAAK,WAAY,KACnD,KAAK,aAAa,MAAO,SAAU,GAAG,WAAW;AAAA,MAClD,WAAW,CAAE,SAAU;AACtB,cAAM,MAAM,kBAAmB,KAAK,YAAY,KAAK,CAAE;AACvD,eAAO,YAAa,aAAa;AAAA,UAChC;AAAA,UACA,GAAG,sBAAuB,GAAI,GAAG;AAAA,QAClC,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AAAA,EACA,IAAI;AAAA,IACH;AAAA,MACC,MAAM;AAAA,MACN,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,SAAS,CAAE,EAAE,IAAI,MAAO,CAAC,CAAE;AAAA,MAC3B,WAAW,CAAE,EAAE,KAAK,SAAS,UAAU,MAAO;AAC7C,YAAI,QAAQ,YAAa,GAAI,KAAM,GAAI;AACvC,YAAK,SAAS,KAAK,GAAI;AACtB,mBAAS,SAAU,OAAQ;AAAA,QAC5B;AACA,eAAO,YAAa,kBAAkB;AAAA,UACrC,SAAS;AAAA,UACT,WAAW,yBAA0B,SAAU;AAAA,QAChD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { isURL, getFilename } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport {\n\tfindMoreSuitableBlock,\n\trewriteXToTwitter,\n\tremoveAspectRatioClasses,\n} from './util';\n\nconst { name: EMBED_BLOCK } = metadata;\n\n/**\n * Default transforms for generic embeds.\n */\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tisMatch: ( node ) => {\n\t\t\t\tif ( node.nodeName !== 'P' ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tconst trimmed = node.textContent.trim();\n\t\t\t\tif (\n\t\t\t\t\t! isURL( trimmed ) ||\n\t\t\t\t\t! /^https:\\/\\//i.test( trimmed ) ||\n\t\t\t\t\ttrimmed.match( /https:\\/\\//gi )?.length !== 1\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\t// Reject URLs whose filename ends in a file extension,\n\t\t\t\t// except common page extensions used by permalinks.\n\t\t\t\treturn ! /\\.(?!(html?|php)$)[a-z0-9]+$/i.test(\n\t\t\t\t\tgetFilename( trimmed ) || ''\n\t\t\t\t);\n\t\t\t},\n\t\t\ttransform: ( node ) => {\n\t\t\t\tconst url = rewriteXToTwitter( node.textContent.trim() );\n\t\t\t\treturn createBlock( EMBED_BLOCK, {\n\t\t\t\t\turl,\n\t\t\t\t\t...findMoreSuitableBlock( url )?.attributes,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'shortcode',\n\t\t\ttag: 'embed',\n\t\t\ttransform: ( _attrs, { shortcode } ) => {\n\t\t\t\tconst url = rewriteXToTwitter( shortcode.content?.trim() );\n\t\t\t\treturn createBlock( EMBED_BLOCK, {\n\t\t\t\t\turl,\n\t\t\t\t\t...findMoreSuitableBlock( url )?.attributes,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\tisMatch: ( { url } ) => !! url,\n\t\t\ttransform: ( { url, caption, className } ) => {\n\t\t\t\tlet value = `<a href=\"${ url }\">${ url }</a>`;\n\t\t\t\tif ( caption?.trim() ) {\n\t\t\t\t\tvalue += `<br />${ caption }`;\n\t\t\t\t}\n\t\t\t\treturn createBlock( 'core/paragraph', {\n\t\t\t\t\tcontent: value,\n\t\t\t\t\tclassName: removeAspectRatioClasses( className ),\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],
5
+ "mappings": ";AAGA,SAAS,mBAAmB;AAC5B,SAAS,OAAO,mBAAmB;AAKnC,OAAO,cAAc;AACrB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,IAAM,EAAE,MAAM,YAAY,IAAI;AAK9B,IAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA,MACN,SAAS,CAAE,SAAU;AACpB,YAAK,KAAK,aAAa,KAAM;AAC5B,iBAAO;AAAA,QACR;AACA,cAAM,UAAU,KAAK,YAAY,KAAK;AACtC,YACC,CAAE,MAAO,OAAQ,KACjB,CAAE,eAAe,KAAM,OAAQ,KAC/B,QAAQ,MAAO,cAAe,GAAG,WAAW,GAC3C;AACD,iBAAO;AAAA,QACR;AAGA,eAAO,CAAE,gCAAgC;AAAA,UACxC,YAAa,OAAQ,KAAK;AAAA,QAC3B;AAAA,MACD;AAAA,MACA,WAAW,CAAE,SAAU;AACtB,cAAM,MAAM,kBAAmB,KAAK,YAAY,KAAK,CAAE;AACvD,eAAO,YAAa,aAAa;AAAA,UAChC;AAAA,UACA,GAAG,sBAAuB,GAAI,GAAG;AAAA,QAClC,CAAE;AAAA,MACH;AAAA,IACD;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,KAAK;AAAA,MACL,WAAW,CAAE,QAAQ,EAAE,UAAU,MAAO;AACvC,cAAM,MAAM,kBAAmB,UAAU,SAAS,KAAK,CAAE;AACzD,eAAO,YAAa,aAAa;AAAA,UAChC;AAAA,UACA,GAAG,sBAAuB,GAAI,GAAG;AAAA,QAClC,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AAAA,EACA,IAAI;AAAA,IACH;AAAA,MACC,MAAM;AAAA,MACN,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,SAAS,CAAE,EAAE,IAAI,MAAO,CAAC,CAAE;AAAA,MAC3B,WAAW,CAAE,EAAE,KAAK,SAAS,UAAU,MAAO;AAC7C,YAAI,QAAQ,YAAa,GAAI,KAAM,GAAI;AACvC,YAAK,SAAS,KAAK,GAAI;AACtB,mBAAS,SAAU,OAAQ;AAAA,QAC5B;AACA,eAAO,YAAa,kBAAkB;AAAA,UACrC,SAAS;AAAA,UACT,WAAW,yBAA0B,SAAU;AAAA,QAChD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,25 +1,13 @@
1
1
  // packages/block-library/src/freeform/convert-to-blocks-button.js
2
2
  import { __ } from "@wordpress/i18n";
3
3
  import { ToolbarButton } from "@wordpress/components";
4
- import { useDispatch, useSelect } from "@wordpress/data";
5
- import { rawHandler, serialize } from "@wordpress/blocks";
6
- import { store as blockEditorStore } from "@wordpress/block-editor";
4
+ import { rawHandler } from "@wordpress/blocks";
7
5
  import { jsx } from "react/jsx-runtime";
8
- var ConvertToBlocksButton = ({ clientId }) => {
9
- const { replaceBlocks } = useDispatch(blockEditorStore);
10
- const block = useSelect(
11
- (select) => {
12
- return select(blockEditorStore).getBlock(clientId);
13
- },
14
- [clientId]
15
- );
6
+ var ConvertToBlocksButton = ({ content, onReplace }) => {
16
7
  return /* @__PURE__ */ jsx(
17
8
  ToolbarButton,
18
9
  {
19
- onClick: () => replaceBlocks(
20
- block.clientId,
21
- rawHandler({ HTML: serialize(block) })
22
- ),
10
+ onClick: () => onReplace(rawHandler({ HTML: content })),
23
11
  children: __("Convert to blocks")
24
12
  }
25
13
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/freeform/convert-to-blocks-button.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { rawHandler, serialize } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst ConvertToBlocksButton = ( { clientId } ) => {\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst block = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( blockEditorStore ).getBlock( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\treturn (\n\t\t<ToolbarButton\n\t\t\tonClick={ () =>\n\t\t\t\treplaceBlocks(\n\t\t\t\t\tblock.clientId,\n\t\t\t\t\trawHandler( { HTML: serialize( block ) } )\n\t\t\t\t)\n\t\t\t}\n\t\t>\n\t\t\t{ __( 'Convert to blocks' ) }\n\t\t</ToolbarButton>\n\t);\n};\n\nexport default ConvertToBlocksButton;\n"],
5
- "mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,qBAAqB;AAC9B,SAAS,aAAa,iBAAiB;AACvC,SAAS,YAAY,iBAAiB;AACtC,SAAS,SAAS,wBAAwB;AAYxC;AAVF,IAAM,wBAAwB,CAAE,EAAE,SAAS,MAAO;AACjD,QAAM,EAAE,cAAc,IAAI,YAAa,gBAAiB;AACxD,QAAM,QAAQ;AAAA,IACb,CAAE,WAAY;AACb,aAAO,OAAQ,gBAAiB,EAAE,SAAU,QAAS;AAAA,IACtD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAU,MACT;AAAA,QACC,MAAM;AAAA,QACN,WAAY,EAAE,MAAM,UAAW,KAAM,EAAE,CAAE;AAAA,MAC1C;AAAA,MAGC,aAAI,mBAAoB;AAAA;AAAA,EAC3B;AAEF;AAEA,IAAO,mCAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ToolbarButton } from '@wordpress/components';\nimport { rawHandler } from '@wordpress/blocks';\n\nconst ConvertToBlocksButton = ( { content, onReplace } ) => {\n\treturn (\n\t\t<ToolbarButton\n\t\t\tonClick={ () => onReplace( rawHandler( { HTML: content } ) ) }\n\t\t>\n\t\t\t{ __( 'Convert to blocks' ) }\n\t\t</ToolbarButton>\n\t);\n};\n\nexport default ConvertToBlocksButton;\n"],
5
+ "mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAIzB;AAFF,IAAM,wBAAwB,CAAE,EAAE,SAAS,UAAU,MAAO;AAC3D,SACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAU,MAAM,UAAW,WAAY,EAAE,MAAM,QAAQ,CAAE,CAAE;AAAA,MAEzD,aAAI,mBAAoB;AAAA;AAAA,EAC3B;AAEF;AAEA,IAAO,mCAAQ;",
6
6
  "names": []
7
7
  }
@@ -5,7 +5,7 @@ import {
5
5
  useBlockProps,
6
6
  store as blockEditorStore
7
7
  } from "@wordpress/block-editor";
8
- import { useSelect } from "@wordpress/data";
8
+ import { useDispatch, useSelect } from "@wordpress/data";
9
9
  import {
10
10
  Button,
11
11
  Placeholder,
@@ -16,12 +16,14 @@ import { useState, useRef, RawHTML } from "@wordpress/element";
16
16
  import { __ } from "@wordpress/i18n";
17
17
  import { classic } from "@wordpress/icons";
18
18
  import ConvertToBlocksButton from "./convert-to-blocks-button.mjs";
19
+ import MigrationNotice from "./migration-notice.mjs";
19
20
  import ModalEdit from "./modal.mjs";
20
21
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
21
22
  function FreeformEdit({
22
23
  attributes,
23
24
  setAttributes,
24
- clientId
25
+ clientId,
26
+ onReplace
25
27
  }) {
26
28
  const { content } = attributes;
27
29
  const [isOpen, setOpen] = useState(false);
@@ -30,8 +32,16 @@ function FreeformEdit({
30
32
  (select) => select(blockEditorStore).canRemoveBlock(clientId),
31
33
  [clientId]
32
34
  );
35
+ const { removeBlock } = useDispatch(blockEditorStore);
36
+ const isDeprecationMode = window.__experimentalClassicBlockDeprecation;
33
37
  return /* @__PURE__ */ jsxs(Fragment, { children: [
34
- canRemove && /* @__PURE__ */ jsx(BlockControls, { children: /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(ConvertToBlocksButton, { clientId }) }) }),
38
+ canRemove && !isDeprecationMode && /* @__PURE__ */ jsx(BlockControls, { children: /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(
39
+ ConvertToBlocksButton,
40
+ {
41
+ content,
42
+ onReplace
43
+ }
44
+ ) }) }),
35
45
  /* @__PURE__ */ jsx(BlockControls, { children: /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(
36
46
  ToolbarButton,
37
47
  {
@@ -41,23 +51,41 @@ function FreeformEdit({
41
51
  }
42
52
  ) }) }),
43
53
  /* @__PURE__ */ jsxs("div", { ...useBlockProps(), children: [
44
- content ? /* @__PURE__ */ jsx(RawHTML, { children: content }) : /* @__PURE__ */ jsx(
54
+ isDeprecationMode && canRemove && content && /* @__PURE__ */ jsx(
55
+ MigrationNotice,
56
+ {
57
+ content,
58
+ onReplace
59
+ }
60
+ ),
61
+ content ? /* @__PURE__ */ jsx(RawHTML, { children: content }) : /* @__PURE__ */ jsxs(
45
62
  Placeholder,
46
63
  {
47
64
  icon: /* @__PURE__ */ jsx(BlockIcon, { icon: classic }),
48
65
  label: __("Classic"),
49
- instructions: __(
50
- "Use the classic editor to add content."
51
- ),
52
- children: /* @__PURE__ */ jsx(
53
- Button,
54
- {
55
- __next40pxDefaultSize: true,
56
- variant: "primary",
57
- onClick: () => setOpen(true),
58
- children: __("Edit contents")
59
- }
60
- )
66
+ instructions: isDeprecationMode ? __(
67
+ "The Classic block is being phased out. It\u2019s recommended to use other blocks for the best editing experience."
68
+ ) : __("Use the classic editor to add content."),
69
+ children: [
70
+ isDeprecationMode && canRemove && /* @__PURE__ */ jsx(
71
+ Button,
72
+ {
73
+ __next40pxDefaultSize: true,
74
+ variant: "primary",
75
+ onClick: () => removeBlock(clientId),
76
+ children: __("Remove block")
77
+ }
78
+ ),
79
+ /* @__PURE__ */ jsx(
80
+ Button,
81
+ {
82
+ __next40pxDefaultSize: true,
83
+ variant: isDeprecationMode && canRemove ? "secondary" : "primary",
84
+ onClick: () => setOpen(true),
85
+ children: __("Edit contents")
86
+ }
87
+ )
88
+ ]
61
89
  }
62
90
  ),
63
91
  isOpen && /* @__PURE__ */ jsx(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/freeform/edit.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tPlaceholder,\n\tToolbarGroup,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { useState, useRef, RawHTML } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { classic } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport ConvertToBlocksButton from './convert-to-blocks-button';\nimport ModalEdit from './modal';\n\nexport default function FreeformEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst { content } = attributes;\n\tconst [ isOpen, setOpen ] = useState( false );\n\tconst editButtonRef = useRef( null );\n\n\tconst canRemove = useSelect(\n\t\t( select ) => select( blockEditorStore ).canRemoveBlock( clientId ),\n\t\t[ clientId ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ canRemove && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ConvertToBlocksButton clientId={ clientId } />\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tref={ editButtonRef }\n\t\t\t\t\t\tonClick={ () => setOpen( true ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t</ToolbarButton>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<div { ...useBlockProps() }>\n\t\t\t\t{ content ? (\n\t\t\t\t\t<RawHTML>{ content }</RawHTML>\n\t\t\t\t) : (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ <BlockIcon icon={ classic } /> }\n\t\t\t\t\t\tlabel={ __( 'Classic' ) }\n\t\t\t\t\t\tinstructions={ __(\n\t\t\t\t\t\t\t'Use the classic editor to add content.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ () => setOpen( true ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Edit contents' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Placeholder>\n\t\t\t\t) }\n\t\t\t\t{ isOpen && (\n\t\t\t\t\t<ModalEdit\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tcontent={ content }\n\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\tsetOpen( false );\n\t\t\t\t\t\t\tif ( editButtonRef.current ) {\n\t\t\t\t\t\t\t\teditButtonRef.current.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ ( newContent ) =>\n\t\t\t\t\t\t\tsetAttributes( { content: newContent } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU,QAAQ,eAAe;AAC1C,SAAS,UAAU;AACnB,SAAS,eAAe;AAKxB,OAAO,2BAA2B;AAClC,OAAO,eAAe;AAiBpB,mBAII,KAcH,YAlBD;AAfa,SAAR,aAA+B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,CAAE,QAAQ,OAAQ,IAAI,SAAU,KAAM;AAC5C,QAAM,gBAAgB,OAAQ,IAAK;AAEnC,QAAM,YAAY;AAAA,IACjB,CAAE,WAAY,OAAQ,gBAAiB,EAAE,eAAgB,QAAS;AAAA,IAClE,CAAE,QAAS;AAAA,EACZ;AAEA,SACC,iCACG;AAAA,iBACD,oBAAC,iBACA,8BAAC,gBACA,8BAAC,yBAAsB,UAAsB,GAC9C,GACD;AAAA,IAED,oBAAC,iBACA,8BAAC,gBACA;AAAA,MAAC;AAAA;AAAA,QACA,KAAM;AAAA,QACN,SAAU,MAAM,QAAS,IAAK;AAAA,QAE5B,aAAI,MAAO;AAAA;AAAA,IACd,GACD,GACD;AAAA,IACA,qBAAC,SAAM,GAAG,cAAc,GACrB;AAAA,gBACD,oBAAC,WAAU,mBAAS,IAEpB;AAAA,QAAC;AAAA;AAAA,UACA,MAAO,oBAAC,aAAU,MAAO,SAAU;AAAA,UACnC,OAAQ,GAAI,SAAU;AAAA,UACtB,cAAe;AAAA,YACd;AAAA,UACD;AAAA,UAEA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,SAAU,MAAM,QAAS,IAAK;AAAA,cAE5B,aAAI,eAAgB;AAAA;AAAA,UACvB;AAAA;AAAA,MACD;AAAA,MAEC,UACD;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA,SAAU,MAAM;AACf,oBAAS,KAAM;AACf,gBAAK,cAAc,SAAU;AAC5B,4BAAc,QAAQ,MAAM;AAAA,YAC7B;AAAA,UACD;AAAA,UACA,UAAW,CAAE,eACZ,cAAe,EAAE,SAAS,WAAW,CAAE;AAAA;AAAA,MAEzC;AAAA,OAEF;AAAA,KACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tPlaceholder,\n\tToolbarGroup,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { useState, useRef, RawHTML } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { classic } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport ConvertToBlocksButton from './convert-to-blocks-button';\nimport MigrationNotice from './migration-notice';\nimport ModalEdit from './modal';\n\nexport default function FreeformEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n\tonReplace,\n} ) {\n\tconst { content } = attributes;\n\tconst [ isOpen, setOpen ] = useState( false );\n\tconst editButtonRef = useRef( null );\n\n\tconst canRemove = useSelect(\n\t\t( select ) => select( blockEditorStore ).canRemoveBlock( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { removeBlock } = useDispatch( blockEditorStore );\n\n\t// Gated by an experiment so authors can opt into a stronger nudge to\n\t// migrate Classic block content ahead of its planned deprecation.\n\tconst isDeprecationMode = window.__experimentalClassicBlockDeprecation;\n\n\treturn (\n\t\t<>\n\t\t\t{ canRemove && ! isDeprecationMode && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ConvertToBlocksButton\n\t\t\t\t\t\t\tcontent={ content }\n\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tref={ editButtonRef }\n\t\t\t\t\t\tonClick={ () => setOpen( true ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t</ToolbarButton>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<div { ...useBlockProps() }>\n\t\t\t\t{ isDeprecationMode && canRemove && content && (\n\t\t\t\t\t<MigrationNotice\n\t\t\t\t\t\tcontent={ content }\n\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ content ? (\n\t\t\t\t\t<RawHTML>{ content }</RawHTML>\n\t\t\t\t) : (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ <BlockIcon icon={ classic } /> }\n\t\t\t\t\t\tlabel={ __( 'Classic' ) }\n\t\t\t\t\t\tinstructions={\n\t\t\t\t\t\t\tisDeprecationMode\n\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t'The Classic block is being phased out. It\u2019s recommended to use other blocks for the best editing experience.'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Use the classic editor to add content.' )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ isDeprecationMode && canRemove && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ () => removeBlock( clientId ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Remove block' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\tisDeprecationMode && canRemove\n\t\t\t\t\t\t\t\t\t? 'secondary'\n\t\t\t\t\t\t\t\t\t: 'primary'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => setOpen( true ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Edit contents' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Placeholder>\n\t\t\t\t) }\n\t\t\t\t{ isOpen && (\n\t\t\t\t\t<ModalEdit\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tcontent={ content }\n\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\tsetOpen( false );\n\t\t\t\t\t\t\tif ( editButtonRef.current ) {\n\t\t\t\t\t\t\t\teditButtonRef.current.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ ( newContent ) =>\n\t\t\t\t\t\t\tsetAttributes( { content: newContent } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,aAAa,iBAAiB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU,QAAQ,eAAe;AAC1C,SAAS,UAAU;AACnB,SAAS,eAAe;AAKxB,OAAO,2BAA2B;AAClC,OAAO,qBAAqB;AAC5B,OAAO,eAAe;AAuBpB,mBAII,KA2BD,YA/BH;AArBa,SAAR,aAA+B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,CAAE,QAAQ,OAAQ,IAAI,SAAU,KAAM;AAC5C,QAAM,gBAAgB,OAAQ,IAAK;AAEnC,QAAM,YAAY;AAAA,IACjB,CAAE,WAAY,OAAQ,gBAAiB,EAAE,eAAgB,QAAS;AAAA,IAClE,CAAE,QAAS;AAAA,EACZ;AACA,QAAM,EAAE,YAAY,IAAI,YAAa,gBAAiB;AAItD,QAAM,oBAAoB,OAAO;AAEjC,SACC,iCACG;AAAA,iBAAa,CAAE,qBAChB,oBAAC,iBACA,8BAAC,gBACA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD,GACD,GACD;AAAA,IAED,oBAAC,iBACA,8BAAC,gBACA;AAAA,MAAC;AAAA;AAAA,QACA,KAAM;AAAA,QACN,SAAU,MAAM,QAAS,IAAK;AAAA,QAE5B,aAAI,MAAO;AAAA;AAAA,IACd,GACD,GACD;AAAA,IACA,qBAAC,SAAM,GAAG,cAAc,GACrB;AAAA,2BAAqB,aAAa,WACnC;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA,MAEC,UACD,oBAAC,WAAU,mBAAS,IAEpB;AAAA,QAAC;AAAA;AAAA,UACA,MAAO,oBAAC,aAAU,MAAO,SAAU;AAAA,UACnC,OAAQ,GAAI,SAAU;AAAA,UACtB,cACC,oBACG;AAAA,YACA;AAAA,UACA,IACA,GAAI,wCAAyC;AAAA,UAG/C;AAAA,iCAAqB,aACtB;AAAA,cAAC;AAAA;AAAA,gBACA,uBAAqB;AAAA,gBACrB,SAAQ;AAAA,gBACR,SAAU,MAAM,YAAa,QAAS;AAAA,gBAEpC,aAAI,cAAe;AAAA;AAAA,YACtB;AAAA,YAED;AAAA,cAAC;AAAA;AAAA,gBACA,uBAAqB;AAAA,gBACrB,SACC,qBAAqB,YAClB,cACA;AAAA,gBAEJ,SAAU,MAAM,QAAS,IAAK;AAAA,gBAE5B,aAAI,eAAgB;AAAA;AAAA,YACvB;AAAA;AAAA;AAAA,MACD;AAAA,MAEC,UACD;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA,SAAU,MAAM;AACf,oBAAS,KAAM;AACf,gBAAK,cAAc,SAAU;AAC5B,4BAAc,QAAQ,MAAM;AAAA,YAC7B;AAAA,UACD;AAAA,UACA,UAAW,CAAE,eACZ,cAAe,EAAE,SAAS,WAAW,CAAE;AAAA;AAAA,MAEzC;AAAA,OAEF;AAAA,KACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -10,7 +10,13 @@ var settings = {
10
10
  edit,
11
11
  save
12
12
  };
13
- var init = () => initBlock({ name, metadata, settings });
13
+ var init = () => {
14
+ const supports = {
15
+ ...metadata.supports,
16
+ inserter: !!window?.__needsClassicBlock
17
+ };
18
+ return initBlock({ name, metadata, settings: { ...settings, supports } });
19
+ };
14
20
  export {
15
21
  init,
16
22
  metadata,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/freeform/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { classic as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
5
- "mappings": ";AAGA,SAAS,WAAW,YAAY;AAKhC,OAAO,eAAe;AACtB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AAEjB,IAAM,EAAE,KAAK,IAAI;AAIV,IAAM,WAAW;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AACD;AAEO,IAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { classic as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n\nexport const init = () => {\n\t// Only expose the block in the inserter if the current post actually needs\n\t// a classic block.\n\tconst supports = {\n\t\t...metadata.supports,\n\t\tinserter: !! window?.__needsClassicBlock,\n\t};\n\treturn initBlock( { name, metadata, settings: { ...settings, supports } } );\n};\n"],
5
+ "mappings": ";AAGA,SAAS,WAAW,YAAY;AAKhC,OAAO,eAAe;AACtB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AAEjB,IAAM,EAAE,KAAK,IAAI;AAIV,IAAM,WAAW;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AACD;AAEO,IAAM,OAAO,MAAM;AAGzB,QAAM,WAAW;AAAA,IAChB,GAAG,SAAS;AAAA,IACZ,UAAU,CAAC,CAAE,QAAQ;AAAA,EACtB;AACA,SAAO,UAAW,EAAE,MAAM,UAAU,UAAU,EAAE,GAAG,UAAU,SAAS,EAAE,CAAE;AAC3E;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,37 @@
1
+ // packages/block-library/src/freeform/migration-notice.js
2
+ import { Warning } from "@wordpress/block-editor";
3
+ import { Button } from "@wordpress/components";
4
+ import { createBlock, rawHandler } from "@wordpress/blocks";
5
+ import { __ } from "@wordpress/i18n";
6
+ import { jsx } from "react/jsx-runtime";
7
+ function MigrationNotice({ content, onReplace }) {
8
+ const actions = [
9
+ /* @__PURE__ */ jsx(
10
+ Button,
11
+ {
12
+ __next40pxDefaultSize: true,
13
+ variant: "primary",
14
+ onClick: () => onReplace(rawHandler({ HTML: content })),
15
+ children: __("Convert to blocks")
16
+ },
17
+ "convert-to-blocks"
18
+ ),
19
+ /* @__PURE__ */ jsx(
20
+ Button,
21
+ {
22
+ __next40pxDefaultSize: true,
23
+ variant: "secondary",
24
+ onClick: () => onReplace(createBlock("core/html", { content })),
25
+ children: __("Convert to HTML")
26
+ },
27
+ "convert-to-html"
28
+ )
29
+ ];
30
+ return /* @__PURE__ */ jsx(Warning, { actions, children: __(
31
+ "The Classic block is being phased out. Convert this content to blocks for the best editing experience, or move it to a Custom HTML block to preserve the markup as-is."
32
+ ) });
33
+ }
34
+ export {
35
+ MigrationNotice as default
36
+ };
37
+ //# sourceMappingURL=migration-notice.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/freeform/migration-notice.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Warning } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { createBlock, rawHandler } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Block-level deprecation warning rendered when the\n * `gutenberg-classic-block-deprecation` experiment is enabled.\n *\n * Uses the same `Warning` primitive as `core/missing` so the experience is\n * visually consistent with how the editor already surfaces deprecated blocks,\n * and offers two migration actions - a primary \"Convert to blocks\", and a\n * secondary \"Convert to Custom HTML\".\n *\n * @param {Object} props\n * @param {string} props.content Raw HTML content of the Classic block.\n * @param {Function} props.onReplace Replace the current block with the given blocks.\n */\nexport default function MigrationNotice( { content, onReplace } ) {\n\tconst actions = [\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tkey=\"convert-to-blocks\"\n\t\t\tvariant=\"primary\"\n\t\t\tonClick={ () => onReplace( rawHandler( { HTML: content } ) ) }\n\t\t>\n\t\t\t{ __( 'Convert to blocks' ) }\n\t\t</Button>,\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tkey=\"convert-to-html\"\n\t\t\tvariant=\"secondary\"\n\t\t\tonClick={ () =>\n\t\t\t\tonReplace( createBlock( 'core/html', { content } ) )\n\t\t\t}\n\t\t>\n\t\t\t{ __( 'Convert to HTML' ) }\n\t\t</Button>,\n\t];\n\n\treturn (\n\t\t<Warning actions={ actions }>\n\t\t\t{ __(\n\t\t\t\t'The Classic block is being phased out. Convert this content to blocks for the best editing experience, or move it to a Custom HTML block to preserve the markup as-is.'\n\t\t\t) }\n\t\t</Warning>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,aAAa,kBAAkB;AACxC,SAAS,UAAU;AAiBjB;AAFa,SAAR,gBAAkC,EAAE,SAAS,UAAU,GAAI;AACjE,QAAM,UAAU;AAAA,IACf;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QAErB,SAAQ;AAAA,QACR,SAAU,MAAM,UAAW,WAAY,EAAE,MAAM,QAAQ,CAAE,CAAE;AAAA,QAEzD,aAAI,mBAAoB;AAAA;AAAA,MAJtB;AAAA,IAKL;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QAErB,SAAQ;AAAA,QACR,SAAU,MACT,UAAW,YAAa,aAAa,EAAE,QAAQ,CAAE,CAAE;AAAA,QAGlD,aAAI,iBAAkB;AAAA;AAAA,MANpB;AAAA,IAOL;AAAA,EACD;AAEA,SACC,oBAAC,WAAQ,SACN;AAAA,IACD;AAAA,EACD,GACD;AAEF;",
6
+ "names": []
7
+ }
@@ -56,6 +56,7 @@ import { isExternalImage } from "./edit.mjs";
56
56
  import { Caption } from "../utils/caption.mjs";
57
57
  import { MediaControl } from "../utils/media-control.mjs";
58
58
  import { useToolsPanelDropdownMenuProps } from "../utils/hooks.mjs";
59
+ import { useOpenImageMediaEditorModal } from "./use-open-image-media-editor-modal.mjs";
59
60
  import {
60
61
  MIN_SIZE,
61
62
  ALLOWED_MEDIA_TYPES,
@@ -64,12 +65,9 @@ import {
64
65
  } from "./constants.mjs";
65
66
  import { evalAspectRatio, mediaPosition } from "./utils.mjs";
66
67
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
67
- var {
68
- DimensionsTool,
69
- ResolutionTool,
70
- mediaEditKey,
71
- openMediaEditorModalKey
72
- } = unlock(blockEditorPrivateApis);
68
+ var { DimensionsTool, ResolutionTool, mediaEditKey } = unlock(
69
+ blockEditorPrivateApis
70
+ );
73
71
  var scaleOptions = [
74
72
  {
75
73
  value: "cover",
@@ -283,7 +281,7 @@ function Image({
283
281
  }, [imageElement]);
284
282
  const setRefs = useMergeRefs([setImageElement, setResizeObserved]);
285
283
  const { allowResize = true } = context;
286
- const { image, canUserEdit, attachmentResolutionError } = useSelect(
284
+ const { image, attachmentResolutionError } = useSelect(
287
285
  (select) => {
288
286
  const imageRecord = id && isSingleSelected ? select(coreStore).getEntityRecord(
289
287
  "postType",
@@ -300,17 +298,8 @@ function Image({
300
298
  { context: "view" }
301
299
  ]
302
300
  ) : null;
303
- let canEdit = false;
304
- if (imageRecord && window?.__experimentalMediaEditor) {
305
- canEdit = !!select(coreStore).canUser("update", {
306
- kind: "postType",
307
- name: "attachment",
308
- id
309
- });
310
- }
311
301
  return {
312
302
  image: imageRecord,
313
- canUserEdit: canEdit,
314
303
  attachmentResolutionError: resolutionError
315
304
  };
316
305
  },
@@ -326,12 +315,12 @@ function Image({
326
315
  (select) => {
327
316
  const { getBlockRootClientId, canInsertBlockType, getSettings: getSettings2 } = select(blockEditorStore);
328
317
  const rootClientId = getBlockRootClientId(clientId);
329
- const settings2 = getSettings2();
318
+ const settings = getSettings2();
330
319
  return {
331
- imageEditing: settings2.imageEditing,
332
- imageSizes: settings2.imageSizes,
333
- maxWidth: settings2.maxWidth,
334
- editMediaEntity: settings2?.[mediaEditKey],
320
+ imageEditing: settings.imageEditing,
321
+ imageSizes: settings.imageSizes,
322
+ maxWidth: settings.maxWidth,
323
+ editMediaEntity: settings?.[mediaEditKey],
335
324
  canInsertCover: canInsertBlockType(
336
325
  "core/cover",
337
326
  rootClientId
@@ -341,20 +330,10 @@ function Image({
341
330
  [clientId]
342
331
  );
343
332
  const { getBlock, getSettings } = useSelect(blockEditorStore);
344
- const settings = getSettings();
345
- const { onNavigateToEntityRecord } = settings;
346
- const openMediaEditorModal = settings[openMediaEditorModalKey];
347
- const handleMediaUpdate = useCallback(
348
- ({ id: newId, url: newUrl }) => {
349
- if (typeof newId === "number" && newId !== id) {
350
- setAttributes({
351
- id: newId,
352
- url: newUrl ?? url
353
- });
354
- }
355
- },
356
- [id, url, setAttributes]
357
- );
333
+ const openImageMediaEditorModal = useOpenImageMediaEditorModal({
334
+ attributes,
335
+ setAttributes
336
+ });
358
337
  const {
359
338
  replaceBlocks,
360
339
  toggleSelection,
@@ -668,18 +647,6 @@ function Image({
668
647
  }
669
648
  ) });
670
649
  const hasDataFormBlockFields = window?.__experimentalContentOnlyInspectorFields;
671
- const editMediaButton = window?.__experimentalMediaEditor && id && isSingleSelected && canUserEdit && !!editMediaEntity && !isExternalImage(id, url) && !isEditingImage && onNavigateToEntityRecord && /* @__PURE__ */ jsx(BlockControls, { group: "other", children: /* @__PURE__ */ jsx(
672
- ToolbarButton,
673
- {
674
- onClick: () => {
675
- onNavigateToEntityRecord({
676
- postId: id,
677
- postType: "attachment"
678
- });
679
- },
680
- children: __("Edit media")
681
- }
682
- ) });
683
650
  const controls = /* @__PURE__ */ jsxs(Fragment, { children: [
684
651
  showBlockControls && /* @__PURE__ */ jsxs(BlockControls, { group: "block", children: [
685
652
  showUrlInput && /* @__PURE__ */ jsx(
@@ -702,10 +669,8 @@ function Image({
702
669
  allowCrop && /* @__PURE__ */ jsx(
703
670
  ToolbarButton,
704
671
  {
705
- onClick: openMediaEditorModal && id ? () => openMediaEditorModal({
706
- id,
707
- onUpdate: handleMediaUpdate
708
- }) : () => setIsEditingImage(true),
672
+ onClick: openImageMediaEditorModal ? openImageMediaEditorModal : () => setIsEditingImage(true),
673
+ "aria-haspopup": openImageMediaEditorModal ? "dialog" : void 0,
709
674
  icon: crop,
710
675
  label: __("Crop")
711
676
  }
@@ -1066,7 +1031,6 @@ function Image({
1066
1031
  };
1067
1032
  const featuredImageControl = !isDescendentOfQueryLoop && postId && id ? /* @__PURE__ */ jsx(BlockSettingsMenuControls, { children: ({ canEdit, selectedClientIds }) => canEdit && selectedClientIds.length === 1 && clientId === selectedClientIds[0] && /* @__PURE__ */ jsx(MenuItem, { onClick: setPostFeatureImage, children: __("Set as featured image") }) }) : null;
1068
1033
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1069
- editMediaButton,
1070
1034
  mediaReplaceFlow,
1071
1035
  controls,
1072
1036
  featuredImageControl,