@wordpress/block-editor 15.11.1-next.v.0 → 15.12.1-next.v.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 (201) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-breadcrumb/index.cjs +10 -2
  3. package/build/components/block-breadcrumb/index.cjs.map +2 -2
  4. package/build/components/block-inspector/index.cjs +11 -11
  5. package/build/components/block-inspector/index.cjs.map +3 -3
  6. package/build/components/block-list/block.cjs +6 -3
  7. package/build/components/block-list/block.cjs.map +3 -3
  8. package/build/components/block-list/index.cjs +26 -18
  9. package/build/components/block-list/index.cjs.map +2 -2
  10. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +2 -6
  11. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
  12. package/build/components/block-list/use-in-between-inserter.cjs +4 -4
  13. package/build/components/block-list/use-in-between-inserter.cjs.map +2 -2
  14. package/build/components/block-settings-menu/block-settings-dropdown.cjs +10 -7
  15. package/build/components/block-settings-menu/block-settings-dropdown.cjs.map +2 -2
  16. package/build/components/block-settings-menu-controls/edit-section-menu-item.cjs +1 -1
  17. package/build/components/block-settings-menu-controls/edit-section-menu-item.cjs.map +2 -2
  18. package/build/components/block-settings-menu-controls/index.cjs +10 -15
  19. package/build/components/block-settings-menu-controls/index.cjs.map +2 -2
  20. package/build/components/block-toolbar/block-toolbar-icon.cjs +6 -4
  21. package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
  22. package/build/components/block-toolbar/index.cjs +1 -1
  23. package/build/components/block-toolbar/index.cjs.map +2 -2
  24. package/build/components/block-variation-transforms/index.cjs +1 -2
  25. package/build/components/block-variation-transforms/index.cjs.map +2 -2
  26. package/build/components/block-visibility/modal.cjs +5 -92
  27. package/build/components/block-visibility/modal.cjs.map +2 -2
  28. package/build/components/inserter/index.cjs +1 -0
  29. package/build/components/inserter/index.cjs.map +2 -2
  30. package/build/components/inspector-controls/last-item.cjs +41 -0
  31. package/build/components/inspector-controls/last-item.cjs.map +7 -0
  32. package/build/components/inspector-controls-tabs/index.cjs +2 -2
  33. package/build/components/inspector-controls-tabs/index.cjs.map +3 -3
  34. package/build/components/inspector-controls-tabs/styles-tab.cjs +4 -4
  35. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  36. package/build/components/media-replace-flow/index.cjs +2 -2
  37. package/build/components/media-replace-flow/index.cjs.map +2 -2
  38. package/build/components/rich-text/index.cjs +1 -1
  39. package/build/components/rich-text/index.cjs.map +2 -2
  40. package/build/components/use-block-display-information/index.cjs +1 -1
  41. package/build/components/use-block-display-information/index.cjs.map +2 -2
  42. package/build/components/writing-flow/index.cjs +2 -0
  43. package/build/components/writing-flow/index.cjs.map +2 -2
  44. package/build/components/writing-flow/use-arrow-nav.cjs +3 -0
  45. package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
  46. package/build/components/writing-flow/use-drag-selection.cjs +2 -1
  47. package/build/components/writing-flow/use-drag-selection.cjs.map +2 -2
  48. package/build/components/writing-flow/use-preview-mode-nav.cjs +92 -0
  49. package/build/components/writing-flow/use-preview-mode-nav.cjs.map +7 -0
  50. package/build/hooks/anchor.cjs +1 -1
  51. package/build/hooks/anchor.cjs.map +1 -1
  52. package/build/hooks/block-renaming.cjs +1 -1
  53. package/build/hooks/block-renaming.cjs.map +2 -2
  54. package/build/hooks/custom-css.cjs +1 -1
  55. package/build/hooks/custom-css.cjs.map +2 -2
  56. package/build/hooks/grid-visualizer.cjs +42 -5
  57. package/build/hooks/grid-visualizer.cjs.map +3 -3
  58. package/build/hooks/index.cjs +0 -2
  59. package/build/hooks/index.cjs.map +3 -3
  60. package/build/hooks/layout-child.cjs +41 -5
  61. package/build/hooks/layout-child.cjs.map +3 -3
  62. package/build/private-apis.cjs +2 -0
  63. package/build/private-apis.cjs.map +3 -3
  64. package/build/store/actions.cjs +5 -0
  65. package/build/store/actions.cjs.map +2 -2
  66. package/build/store/private-selectors.cjs +1 -1
  67. package/build/store/private-selectors.cjs.map +2 -2
  68. package/build/store/reducer.cjs +5 -7
  69. package/build/store/reducer.cjs.map +2 -2
  70. package/build/store/selectors.cjs +15 -0
  71. package/build/store/selectors.cjs.map +2 -2
  72. package/build/utils/fit-text-utils.cjs +17 -7
  73. package/build/utils/fit-text-utils.cjs.map +2 -2
  74. package/build-module/components/block-breadcrumb/index.mjs +10 -2
  75. package/build-module/components/block-breadcrumb/index.mjs.map +2 -2
  76. package/build-module/components/block-inspector/index.mjs +12 -11
  77. package/build-module/components/block-inspector/index.mjs.map +2 -2
  78. package/build-module/components/block-list/block.mjs +6 -3
  79. package/build-module/components/block-list/block.mjs.map +3 -3
  80. package/build-module/components/block-list/index.mjs +26 -18
  81. package/build-module/components/block-list/index.mjs.map +2 -2
  82. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +2 -6
  83. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
  84. package/build-module/components/block-list/use-in-between-inserter.mjs +4 -4
  85. package/build-module/components/block-list/use-in-between-inserter.mjs.map +2 -2
  86. package/build-module/components/block-settings-menu/block-settings-dropdown.mjs +10 -7
  87. package/build-module/components/block-settings-menu/block-settings-dropdown.mjs.map +2 -2
  88. package/build-module/components/block-settings-menu-controls/edit-section-menu-item.mjs +1 -1
  89. package/build-module/components/block-settings-menu-controls/edit-section-menu-item.mjs.map +2 -2
  90. package/build-module/components/block-settings-menu-controls/index.mjs +10 -15
  91. package/build-module/components/block-settings-menu-controls/index.mjs.map +2 -2
  92. package/build-module/components/block-toolbar/block-toolbar-icon.mjs +6 -4
  93. package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
  94. package/build-module/components/block-toolbar/index.mjs +1 -1
  95. package/build-module/components/block-toolbar/index.mjs.map +2 -2
  96. package/build-module/components/block-variation-transforms/index.mjs +1 -2
  97. package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
  98. package/build-module/components/block-visibility/modal.mjs +5 -92
  99. package/build-module/components/block-visibility/modal.mjs.map +2 -2
  100. package/build-module/components/inserter/index.mjs +1 -0
  101. package/build-module/components/inserter/index.mjs.map +2 -2
  102. package/build-module/components/inspector-controls/last-item.mjs +23 -0
  103. package/build-module/components/inspector-controls/last-item.mjs.map +7 -0
  104. package/build-module/components/inspector-controls-tabs/index.mjs +2 -2
  105. package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
  106. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +4 -4
  107. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  108. package/build-module/components/media-replace-flow/index.mjs +2 -2
  109. package/build-module/components/media-replace-flow/index.mjs.map +2 -2
  110. package/build-module/components/rich-text/index.mjs +1 -1
  111. package/build-module/components/rich-text/index.mjs.map +2 -2
  112. package/build-module/components/use-block-display-information/index.mjs +1 -1
  113. package/build-module/components/use-block-display-information/index.mjs.map +2 -2
  114. package/build-module/components/writing-flow/index.mjs +2 -0
  115. package/build-module/components/writing-flow/index.mjs.map +2 -2
  116. package/build-module/components/writing-flow/use-arrow-nav.mjs +3 -0
  117. package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
  118. package/build-module/components/writing-flow/use-drag-selection.mjs +2 -1
  119. package/build-module/components/writing-flow/use-drag-selection.mjs.map +2 -2
  120. package/build-module/components/writing-flow/use-preview-mode-nav.mjs +67 -0
  121. package/build-module/components/writing-flow/use-preview-mode-nav.mjs.map +7 -0
  122. package/build-module/hooks/anchor.mjs +1 -1
  123. package/build-module/hooks/anchor.mjs.map +1 -1
  124. package/build-module/hooks/block-renaming.mjs +1 -1
  125. package/build-module/hooks/block-renaming.mjs.map +2 -2
  126. package/build-module/hooks/custom-css.mjs +1 -1
  127. package/build-module/hooks/custom-css.mjs.map +2 -2
  128. package/build-module/hooks/grid-visualizer.mjs +20 -5
  129. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  130. package/build-module/hooks/index.mjs +0 -2
  131. package/build-module/hooks/index.mjs.map +2 -2
  132. package/build-module/hooks/layout-child.mjs +31 -5
  133. package/build-module/hooks/layout-child.mjs.map +2 -2
  134. package/build-module/private-apis.mjs +2 -0
  135. package/build-module/private-apis.mjs.map +2 -2
  136. package/build-module/store/actions.mjs +5 -0
  137. package/build-module/store/actions.mjs.map +2 -2
  138. package/build-module/store/private-selectors.mjs +1 -1
  139. package/build-module/store/private-selectors.mjs.map +2 -2
  140. package/build-module/store/reducer.mjs +5 -7
  141. package/build-module/store/reducer.mjs.map +2 -2
  142. package/build-module/store/selectors.mjs +15 -0
  143. package/build-module/store/selectors.mjs.map +2 -2
  144. package/build-module/utils/fit-text-utils.mjs +17 -7
  145. package/build-module/utils/fit-text-utils.mjs.map +2 -2
  146. package/build-style/content-rtl.css +10 -0
  147. package/build-style/content.css +10 -0
  148. package/package.json +39 -39
  149. package/src/components/block-breadcrumb/index.js +6 -1
  150. package/src/components/block-inspector/index.js +20 -21
  151. package/src/components/block-list/block.js +5 -2
  152. package/src/components/block-list/content.scss +11 -0
  153. package/src/components/block-list/index.js +25 -17
  154. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +2 -7
  155. package/src/components/block-list/use-in-between-inserter.js +8 -6
  156. package/src/components/block-settings-menu/block-settings-dropdown.js +11 -6
  157. package/src/components/block-settings-menu-controls/edit-section-menu-item.js +1 -7
  158. package/src/components/block-settings-menu-controls/index.js +14 -16
  159. package/src/components/block-toolbar/block-toolbar-icon.js +6 -10
  160. package/src/components/block-toolbar/index.js +1 -7
  161. package/src/components/block-variation-transforms/index.js +1 -4
  162. package/src/components/inserter/index.js +1 -0
  163. package/src/components/inserter/stories/index.story.jsx +31 -24
  164. package/src/components/inspector-controls/last-item.js +29 -0
  165. package/src/components/inspector-controls-tabs/index.js +1 -1
  166. package/src/components/inspector-controls-tabs/styles-tab.js +10 -11
  167. package/src/components/media-replace-flow/index.js +3 -3
  168. package/src/components/rich-text/index.js +1 -1
  169. package/src/components/use-block-display-information/index.js +1 -5
  170. package/src/components/writing-flow/index.js +2 -0
  171. package/src/components/writing-flow/use-arrow-nav.js +5 -0
  172. package/src/components/writing-flow/use-drag-selection.js +7 -1
  173. package/src/components/writing-flow/use-preview-mode-nav.js +102 -0
  174. package/src/hooks/anchor.js +1 -1
  175. package/src/hooks/block-renaming.js +5 -2
  176. package/src/hooks/custom-css.js +1 -1
  177. package/src/hooks/grid-visualizer.js +23 -4
  178. package/src/hooks/index.js +0 -2
  179. package/src/hooks/layout-child.js +39 -3
  180. package/src/private-apis.js +2 -0
  181. package/src/store/actions.js +7 -0
  182. package/src/store/private-selectors.js +0 -1
  183. package/src/store/reducer.js +11 -18
  184. package/src/store/selectors.js +25 -0
  185. package/src/store/test/reducer.js +258 -266
  186. package/src/utils/fit-text-utils.js +24 -8
  187. package/build/components/content-lock/index.cjs +0 -31
  188. package/build/components/content-lock/index.cjs.map +0 -7
  189. package/build/components/content-lock/modify-content-lock-menu-item.cjs +0 -70
  190. package/build/components/content-lock/modify-content-lock-menu-item.cjs.map +0 -7
  191. package/build/hooks/content-lock-ui.cjs +0 -68
  192. package/build/hooks/content-lock-ui.cjs.map +0 -7
  193. package/build-module/components/content-lock/index.mjs +0 -6
  194. package/build-module/components/content-lock/index.mjs.map +0 -7
  195. package/build-module/components/content-lock/modify-content-lock-menu-item.mjs +0 -45
  196. package/build-module/components/content-lock/modify-content-lock-menu-item.mjs.map +0 -7
  197. package/build-module/hooks/content-lock-ui.mjs +0 -47
  198. package/build-module/hooks/content-lock-ui.mjs.map +0 -7
  199. package/src/components/content-lock/index.js +0 -1
  200. package/src/components/content-lock/modify-content-lock-menu-item.js +0 -67
  201. package/src/hooks/content-lock-ui.js +0 -76
@@ -3977,6 +3977,9 @@ describe( 'state', () => {
3977
3977
  expect( editingState.derivedBlockEditingModes ).toEqual(
3978
3978
  new Map(
3979
3979
  Object.entries( {
3980
+ // blocks outside the section are disabled.
3981
+ '': 'disabled',
3982
+ // blocks inside the section are fully editable.
3980
3983
  'group-1': 'default',
3981
3984
  'paragraph-1': 'default',
3982
3985
  'group-2': 'default',
@@ -4086,9 +4089,13 @@ describe( 'state', () => {
4086
4089
  expect( editingSection1.derivedBlockEditingModes ).toEqual(
4087
4090
  new Map(
4088
4091
  Object.entries( {
4092
+ // Blocks outside the section are disabled.
4093
+ '': 'disabled',
4094
+ 'section-2': 'disabled',
4095
+ 'section-2-paragraph': 'disabled',
4096
+ // Block inside the section are fully editable.
4089
4097
  'section-1': 'default',
4090
4098
  'section-1-paragraph': 'default',
4091
- 'section-2-paragraph': 'contentOnly',
4092
4099
  } )
4093
4100
  )
4094
4101
  );
@@ -4287,294 +4294,279 @@ describe( 'state', () => {
4287
4294
  } );
4288
4295
  } );
4289
4296
 
4290
- // Tests for the contentOnly experiments pattern.
4291
- // If/when the experiment is stabilized, this wrapping `describe` and
4292
- // `beforeAll`/`afterAll` can be removed, un-nesting the tests within.
4293
- describe( 'contentOnly patterns experiment', () => {
4297
+ describe( 'unsynced patterns', () => {
4298
+ let initialState;
4294
4299
  beforeAll( () => {
4295
- globalThis.window.__experimentalContentOnlyPatternInsertion = true;
4296
- } );
4297
-
4298
- afterAll( () => {
4299
- delete globalThis.window
4300
- .__experimentalContentOnlyPatternInsertion;
4301
- } );
4302
-
4303
- describe( 'unsynced patterns', () => {
4304
- let initialState;
4305
- beforeAll( () => {
4306
- initialState = dispatchActions(
4307
- [
4308
- {
4309
- type: 'RESET_BLOCKS',
4310
- blocks: [
4311
- {
4312
- name: 'core/group',
4313
- clientId: 'group-1',
4314
- attributes: {
4315
- metadata: {
4316
- patternName: 'test-pattern',
4317
- },
4300
+ initialState = dispatchActions(
4301
+ [
4302
+ {
4303
+ type: 'RESET_BLOCKS',
4304
+ blocks: [
4305
+ {
4306
+ name: 'core/group',
4307
+ clientId: 'group-1',
4308
+ attributes: {
4309
+ metadata: {
4310
+ patternName: 'test-pattern',
4318
4311
  },
4319
- innerBlocks: [
4320
- {
4321
- name: 'core/paragraph',
4322
- clientId: 'paragraph-1',
4323
- attributes: {},
4324
- innerBlocks: [],
4325
- },
4326
- {
4327
- name: 'core/group',
4328
- clientId: 'group-2',
4329
- attributes: {},
4330
- innerBlocks: [
4331
- {
4332
- name: 'core/paragraph',
4333
- clientId: 'paragraph-2',
4334
- attributes: {},
4335
- innerBlocks: [],
4336
- },
4337
- ],
4338
- },
4339
- ],
4340
4312
  },
4341
- ],
4342
- },
4343
- ],
4344
- testReducer,
4345
- initialState
4346
- );
4347
- } );
4313
+ innerBlocks: [
4314
+ {
4315
+ name: 'core/paragraph',
4316
+ clientId: 'paragraph-1',
4317
+ attributes: {},
4318
+ innerBlocks: [],
4319
+ },
4320
+ {
4321
+ name: 'core/group',
4322
+ clientId: 'group-2',
4323
+ attributes: {},
4324
+ innerBlocks: [
4325
+ {
4326
+ name: 'core/paragraph',
4327
+ clientId: 'paragraph-2',
4328
+ attributes: {},
4329
+ innerBlocks: [],
4330
+ },
4331
+ ],
4332
+ },
4333
+ ],
4334
+ },
4335
+ ],
4336
+ },
4337
+ ],
4338
+ testReducer,
4339
+ initialState
4340
+ );
4341
+ } );
4348
4342
 
4349
- it( 'returns the expected block editing modes for an unsynced pattern', () => {
4350
- expect( initialState.derivedBlockEditingModes ).toEqual(
4351
- new Map(
4352
- Object.entries( {
4353
- 'paragraph-1': 'contentOnly',
4354
- 'group-2': 'disabled',
4355
- 'paragraph-2': 'contentOnly',
4356
- } )
4357
- )
4358
- );
4359
- } );
4343
+ it( 'returns the expected block editing modes for an unsynced pattern', () => {
4344
+ expect( initialState.derivedBlockEditingModes ).toEqual(
4345
+ new Map(
4346
+ Object.entries( {
4347
+ 'paragraph-1': 'contentOnly',
4348
+ 'group-2': 'disabled',
4349
+ 'paragraph-2': 'contentOnly',
4350
+ } )
4351
+ )
4352
+ );
4353
+ } );
4360
4354
 
4361
- it( 'removes block editing modes when an unsynced pattern is removed', () => {
4362
- const { derivedBlockEditingModes } = dispatchActions(
4363
- [
4364
- {
4365
- type: 'REMOVE_BLOCKS',
4366
- clientIds: [ 'group-1' ],
4367
- },
4368
- ],
4369
- testReducer,
4370
- initialState
4371
- );
4355
+ it( 'removes block editing modes when an unsynced pattern is removed', () => {
4356
+ const { derivedBlockEditingModes } = dispatchActions(
4357
+ [
4358
+ {
4359
+ type: 'REMOVE_BLOCKS',
4360
+ clientIds: [ 'group-1' ],
4361
+ },
4362
+ ],
4363
+ testReducer,
4364
+ initialState
4365
+ );
4372
4366
 
4373
- expect( derivedBlockEditingModes ).toEqual( new Map() );
4374
- } );
4367
+ expect( derivedBlockEditingModes ).toEqual( new Map() );
4368
+ } );
4375
4369
 
4376
- it( 'removes block editing modes when the `patternName` attribute is removed from the unsynced pattern', () => {
4377
- const { derivedBlockEditingModes } = dispatchActions(
4378
- [
4379
- {
4380
- type: 'UPDATE_BLOCK_ATTRIBUTES',
4381
- clientIds: [ 'group-1' ],
4382
- attributes: {
4383
- metadata: {
4384
- patternName: undefined,
4385
- },
4370
+ it( 'removes block editing modes when the `patternName` attribute is removed from the unsynced pattern', () => {
4371
+ const { derivedBlockEditingModes } = dispatchActions(
4372
+ [
4373
+ {
4374
+ type: 'UPDATE_BLOCK_ATTRIBUTES',
4375
+ clientIds: [ 'group-1' ],
4376
+ attributes: {
4377
+ metadata: {
4378
+ patternName: undefined,
4386
4379
  },
4387
4380
  },
4388
- ],
4389
- testReducer,
4390
- initialState
4391
- );
4381
+ },
4382
+ ],
4383
+ testReducer,
4384
+ initialState
4385
+ );
4392
4386
 
4393
- expect( derivedBlockEditingModes ).toEqual( new Map() );
4394
- } );
4387
+ expect( derivedBlockEditingModes ).toEqual( new Map() );
4388
+ } );
4395
4389
 
4396
- it( 'allows explicitly set blockEditingModes to override the unsynced pattern editing modes', () => {
4397
- const { derivedBlockEditingModes } = dispatchActions(
4398
- [
4399
- {
4400
- type: 'SET_BLOCK_EDITING_MODE',
4401
- clientId: 'paragraph-2',
4402
- mode: 'disabled',
4403
- },
4404
- ],
4405
- testReducer,
4406
- initialState
4407
- );
4390
+ it( 'allows explicitly set blockEditingModes to override the unsynced pattern editing modes', () => {
4391
+ const { derivedBlockEditingModes } = dispatchActions(
4392
+ [
4393
+ {
4394
+ type: 'SET_BLOCK_EDITING_MODE',
4395
+ clientId: 'paragraph-2',
4396
+ mode: 'disabled',
4397
+ },
4398
+ ],
4399
+ testReducer,
4400
+ initialState
4401
+ );
4408
4402
 
4409
- expect( derivedBlockEditingModes ).toEqual(
4410
- new Map(
4411
- Object.entries( {
4412
- 'paragraph-1': 'contentOnly',
4413
- 'group-2': 'disabled',
4414
- // Paragraph 2 already has an explicit mode, so isn't set as a derived mode.
4415
- } )
4416
- )
4417
- );
4418
- } );
4403
+ expect( derivedBlockEditingModes ).toEqual(
4404
+ new Map(
4405
+ Object.entries( {
4406
+ 'paragraph-1': 'contentOnly',
4407
+ 'group-2': 'disabled',
4408
+ // Paragraph 2 already has an explicit mode, so isn't set as a derived mode.
4409
+ } )
4410
+ )
4411
+ );
4412
+ } );
4419
4413
 
4420
- it( 'sets the correct block editing modes when a new unsynced pattern is inserted', () => {
4421
- const { derivedBlockEditingModes } = dispatchActions(
4422
- [
4423
- {
4424
- type: 'INSERT_BLOCKS',
4425
- rootClientId: '',
4426
- index: 1,
4427
- blocks: [
4428
- {
4429
- name: 'core/group',
4430
- clientId: 'group-3',
4431
- attributes: {
4432
- metadata: {
4433
- patternName: 'test-pattern-2',
4434
- },
4414
+ it( 'sets the correct block editing modes when a new unsynced pattern is inserted', () => {
4415
+ const { derivedBlockEditingModes } = dispatchActions(
4416
+ [
4417
+ {
4418
+ type: 'INSERT_BLOCKS',
4419
+ rootClientId: '',
4420
+ index: 1,
4421
+ blocks: [
4422
+ {
4423
+ name: 'core/group',
4424
+ clientId: 'group-3',
4425
+ attributes: {
4426
+ metadata: {
4427
+ patternName: 'test-pattern-2',
4435
4428
  },
4436
- innerBlocks: [
4437
- {
4438
- name: 'core/paragraph',
4439
- clientId: 'paragraph-3',
4440
- attributes: {},
4441
- innerBlocks: [],
4442
- },
4443
- ],
4444
4429
  },
4445
- ],
4446
- },
4447
- ],
4448
- testReducer,
4449
- initialState
4450
- );
4430
+ innerBlocks: [
4431
+ {
4432
+ name: 'core/paragraph',
4433
+ clientId: 'paragraph-3',
4434
+ attributes: {},
4435
+ innerBlocks: [],
4436
+ },
4437
+ ],
4438
+ },
4439
+ ],
4440
+ },
4441
+ ],
4442
+ testReducer,
4443
+ initialState
4444
+ );
4451
4445
 
4452
- expect( derivedBlockEditingModes ).toEqual(
4453
- new Map(
4454
- Object.entries( {
4455
- 'paragraph-1': 'contentOnly',
4456
- 'group-2': 'disabled',
4457
- 'paragraph-2': 'contentOnly',
4458
- 'paragraph-3': 'contentOnly',
4459
- } )
4460
- )
4461
- );
4462
- } );
4446
+ expect( derivedBlockEditingModes ).toEqual(
4447
+ new Map(
4448
+ Object.entries( {
4449
+ 'paragraph-1': 'contentOnly',
4450
+ 'group-2': 'disabled',
4451
+ 'paragraph-2': 'contentOnly',
4452
+ 'paragraph-3': 'contentOnly',
4453
+ } )
4454
+ )
4455
+ );
4463
4456
  } );
4457
+ } );
4464
4458
 
4465
- describe( 'template parts', () => {
4466
- let initialState;
4467
- beforeAll( () => {
4468
- // Simulates how the editor typically inserts controlled blocks,
4469
- // - first the template part is inserted with no inner blocks.
4470
- // - next the template part is marked as a controlled block.
4471
- // - finally, once the inner blocks of the template part are received, they're inserted.
4472
- initialState = dispatchActions(
4473
- [
4474
- {
4475
- type: 'RESET_BLOCKS',
4476
- blocks: [
4477
- {
4478
- name: 'core/template-part',
4479
- clientId: 'template-part',
4480
- attributes: {},
4481
- innerBlocks: [],
4482
- },
4483
- ],
4484
- },
4485
- {
4486
- type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
4487
- clientId: 'template-part',
4488
- hasControlledInnerBlocks: true,
4489
- },
4490
- {
4491
- type: 'REPLACE_INNER_BLOCKS',
4492
- rootClientId: 'template-part',
4493
- blocks: [
4494
- {
4495
- name: 'core/paragraph',
4496
- clientId: 'template-part-paragraph',
4497
- attributes: {},
4498
- innerBlocks: [],
4499
- },
4500
- {
4501
- name: 'core/group',
4502
- clientId: 'template-part-group',
4503
- attributes: {},
4504
- innerBlocks: [
4505
- {
4506
- name: 'core/paragraph',
4507
- clientId:
4508
- 'template-part-grouped-paragraph',
4509
- attributes: {},
4510
- innerBlocks: [],
4511
- },
4512
- ],
4513
- },
4514
- ],
4515
- },
4516
- ],
4517
- testReducer,
4518
- initialState
4519
- );
4520
- } );
4459
+ describe( 'template parts', () => {
4460
+ let initialState;
4461
+ beforeAll( () => {
4462
+ // Simulates how the editor typically inserts controlled blocks,
4463
+ // - first the template part is inserted with no inner blocks.
4464
+ // - next the template part is marked as a controlled block.
4465
+ // - finally, once the inner blocks of the template part are received, they're inserted.
4466
+ initialState = dispatchActions(
4467
+ [
4468
+ {
4469
+ type: 'RESET_BLOCKS',
4470
+ blocks: [
4471
+ {
4472
+ name: 'core/template-part',
4473
+ clientId: 'template-part',
4474
+ attributes: {},
4475
+ innerBlocks: [],
4476
+ },
4477
+ ],
4478
+ },
4479
+ {
4480
+ type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
4481
+ clientId: 'template-part',
4482
+ hasControlledInnerBlocks: true,
4483
+ },
4484
+ {
4485
+ type: 'REPLACE_INNER_BLOCKS',
4486
+ rootClientId: 'template-part',
4487
+ blocks: [
4488
+ {
4489
+ name: 'core/paragraph',
4490
+ clientId: 'template-part-paragraph',
4491
+ attributes: {},
4492
+ innerBlocks: [],
4493
+ },
4494
+ {
4495
+ name: 'core/group',
4496
+ clientId: 'template-part-group',
4497
+ attributes: {},
4498
+ innerBlocks: [
4499
+ {
4500
+ name: 'core/paragraph',
4501
+ clientId:
4502
+ 'template-part-grouped-paragraph',
4503
+ attributes: {},
4504
+ innerBlocks: [],
4505
+ },
4506
+ ],
4507
+ },
4508
+ ],
4509
+ },
4510
+ ],
4511
+ testReducer,
4512
+ initialState
4513
+ );
4514
+ } );
4521
4515
 
4522
- it( 'returns the expected block editing modes for synced patterns', () => {
4523
- expect( initialState.derivedBlockEditingModes ).toEqual(
4524
- new Map(
4525
- Object.entries( {
4526
- 'template-part-paragraph': 'contentOnly',
4527
- 'template-part-group': 'disabled',
4528
- 'template-part-grouped-paragraph':
4529
- 'contentOnly',
4530
- } )
4531
- )
4532
- );
4533
- } );
4516
+ it( 'returns the expected block editing modes for synced patterns', () => {
4517
+ expect( initialState.derivedBlockEditingModes ).toEqual(
4518
+ new Map(
4519
+ Object.entries( {
4520
+ 'template-part-paragraph': 'contentOnly',
4521
+ 'template-part-group': 'disabled',
4522
+ 'template-part-grouped-paragraph': 'contentOnly',
4523
+ } )
4524
+ )
4525
+ );
4526
+ } );
4534
4527
 
4535
- it( 'removes the block editing modes when the template part is removed', () => {
4536
- const { derivedBlockEditingModes } = dispatchActions(
4537
- [
4538
- {
4539
- type: 'REMOVE_BLOCKS',
4540
- clientIds: [ 'template-part' ],
4541
- },
4542
- {
4543
- type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
4544
- clientId: 'template-part',
4545
- hasControlledInnerBlocks: false,
4546
- },
4547
- ],
4548
- testReducer,
4549
- initialState
4550
- );
4528
+ it( 'removes the block editing modes when the template part is removed', () => {
4529
+ const { derivedBlockEditingModes } = dispatchActions(
4530
+ [
4531
+ {
4532
+ type: 'REMOVE_BLOCKS',
4533
+ clientIds: [ 'template-part' ],
4534
+ },
4535
+ {
4536
+ type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
4537
+ clientId: 'template-part',
4538
+ hasControlledInnerBlocks: false,
4539
+ },
4540
+ ],
4541
+ testReducer,
4542
+ initialState
4543
+ );
4551
4544
 
4552
- expect( derivedBlockEditingModes ).toEqual( new Map() );
4553
- } );
4545
+ expect( derivedBlockEditingModes ).toEqual( new Map() );
4546
+ } );
4554
4547
 
4555
- it( 'allows explicitly set blockEditingModes to override the template part editing modes', () => {
4556
- const { derivedBlockEditingModes } = dispatchActions(
4557
- [
4558
- {
4559
- type: 'SET_BLOCK_EDITING_MODE',
4560
- clientId: 'template-part-grouped-paragraph',
4561
- mode: 'disabled',
4562
- },
4563
- ],
4564
- testReducer,
4565
- initialState
4566
- );
4548
+ it( 'allows explicitly set blockEditingModes to override the template part editing modes', () => {
4549
+ const { derivedBlockEditingModes } = dispatchActions(
4550
+ [
4551
+ {
4552
+ type: 'SET_BLOCK_EDITING_MODE',
4553
+ clientId: 'template-part-grouped-paragraph',
4554
+ mode: 'disabled',
4555
+ },
4556
+ ],
4557
+ testReducer,
4558
+ initialState
4559
+ );
4567
4560
 
4568
- expect( derivedBlockEditingModes ).toEqual(
4569
- new Map(
4570
- Object.entries( {
4571
- 'template-part-paragraph': 'contentOnly',
4572
- 'template-part-group': 'disabled',
4573
- // template-part-grouped-paragraph already has an explicit mode, so isn't set as a derived mode.
4574
- } )
4575
- )
4576
- );
4577
- } );
4561
+ expect( derivedBlockEditingModes ).toEqual(
4562
+ new Map(
4563
+ Object.entries( {
4564
+ 'template-part-paragraph': 'contentOnly',
4565
+ 'template-part-group': 'disabled',
4566
+ // template-part-grouped-paragraph already has an explicit mode, so isn't set as a derived mode.
4567
+ } )
4568
+ )
4569
+ );
4578
4570
  } );
4579
4571
  } );
4580
4572
  } );
@@ -18,11 +18,26 @@ function findOptimalFontSize( textElement, applyFontSize ) {
18
18
  let bestSize = minSize;
19
19
 
20
20
  const computedStyle = window.getComputedStyle( textElement );
21
- const paddingLeft = parseFloat( computedStyle.paddingLeft ) || 0;
22
- const paddingRight = parseFloat( computedStyle.paddingRight ) || 0;
21
+ let paddingLeft = parseFloat( computedStyle.paddingLeft ) || 0;
22
+ let paddingRight = parseFloat( computedStyle.paddingRight ) || 0;
23
23
  const range = document.createRange();
24
24
  range.selectNodeContents( textElement );
25
- let maxclientHeight = textElement.clientHeight;
25
+
26
+ let referenceElement = textElement;
27
+ const parentElement = textElement.parentElement;
28
+ if ( parentElement ) {
29
+ const parentElementComputedStyle =
30
+ window.getComputedStyle( parentElement );
31
+ if ( parentElementComputedStyle?.display === 'flex' ) {
32
+ referenceElement = parentElement;
33
+ paddingLeft +=
34
+ parseFloat( parentElementComputedStyle.paddingLeft ) || 0;
35
+ paddingRight +=
36
+ parseFloat( parentElementComputedStyle.paddingRight ) || 0;
37
+ }
38
+ }
39
+ let maxclientHeight = referenceElement.clientHeight;
40
+
26
41
  while ( minSize <= maxSize ) {
27
42
  const midSize = Math.floor( ( minSize + maxSize ) / 2 );
28
43
  applyFontSize( midSize );
@@ -36,12 +51,13 @@ function findOptimalFontSize( textElement, applyFontSize ) {
36
51
  // Check if text fits within the element's width and is not
37
52
  // overflowing into the padding area.
38
53
  const fitsWidth =
39
- textElement.scrollWidth <= textElement.clientWidth &&
40
- textWidth <= textElement.clientWidth - paddingLeft - paddingRight;
54
+ textElement.scrollWidth <= referenceElement.clientWidth &&
55
+ textWidth <=
56
+ referenceElement.clientWidth - paddingLeft - paddingRight;
41
57
  // Check if text fits within the element's height.
42
58
  const fitsHeight =
43
59
  alreadyHasScrollableHeight ||
44
- textElement.scrollHeight <= textElement.clientHeight ||
60
+ textElement.scrollHeight <= referenceElement.clientHeight ||
45
61
  textElement.scrollHeight <= maxclientHeight;
46
62
 
47
63
  // When there are calculated line heights, text may jump in height
@@ -49,8 +65,8 @@ function findOptimalFontSize( textElement, applyFontSize ) {
49
65
  // making text not fit.
50
66
  // We store a maximum reference height: the maximum reference element height that was observed
51
67
  // during the loop to avoid issues with such jumps.
52
- if ( textElement.clientHeight > maxclientHeight ) {
53
- maxclientHeight = textElement.clientHeight;
68
+ if ( referenceElement.clientHeight > maxclientHeight ) {
69
+ maxclientHeight = referenceElement.clientHeight;
54
70
  }
55
71
 
56
72
  if ( fitsWidth && fitsHeight ) {
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/block-editor/src/components/content-lock/index.js
21
- var content_lock_exports = {};
22
- __export(content_lock_exports, {
23
- ModifyContentOnlySectionMenuItem: () => import_modify_content_lock_menu_item.ModifyContentOnlySectionMenuItem
24
- });
25
- module.exports = __toCommonJS(content_lock_exports);
26
- var import_modify_content_lock_menu_item = require("./modify-content-lock-menu-item.cjs");
27
- // Annotate the CommonJS export names for ESM import in node:
28
- 0 && (module.exports = {
29
- ModifyContentOnlySectionMenuItem
30
- });
31
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/content-lock/index.js"],
4
- "sourcesContent": ["export { ModifyContentOnlySectionMenuItem } from './modify-content-lock-menu-item';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2CAAiD;",
6
- "names": []
7
- }