Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First stab at a proof of concept. * Attempt to programmatically determine dest dimensions * Add README stub. * Updates to use default args for width and height Addresses #16113 (comment) * Update class namespaces to match package Addresses #16113 (comment) * Add width and height as Effect Hook deps Addresses #16113 (comment) * Use correct `createRef` from @wordpress/element Was previously using React createRef. Addresses #16113 (comment) * Revert "Update class namespaces to match package" This reverts commit 24252fa887986548839e7d9a6fe2639807ed0bc6. * Migrate to useRef hook * Adds basic unit test Still a WIP * Refactor to avoid unecessary state and simplify implementation of scaling * Add some padding to the preview Avoids Blocks butting up against the edges of the preview, especially if the preview wrapper has rounded corners which can cause the Blocks to be clipped. * Refactor to utilise JS template strings * WIP: Adds zoom for small individual blocks With small individual Blocks showing the preview at “actual size” (even when scaled to fit) is a bit odd. Everything still looks very zoomed out and far away. Updates to check DOM for largest element within the Block and use that width to calculate a “zoomed” scale value so that the contents of the Block itself is shown zoomed in. Still WIP * Updates to target block contents more reliably and to calc entire box model in width * block-preview: render scaled preview in a shadow dom * try: setting styles to shadow dom elements * Revert "try: setting styles to shadow dom elements" This reverts commit ea573f9. The reason being that there is no benefit of using shadow DOM and it introduces additional complexity. * Removes attempt at auto zoom on Block contents After much experimenting we’ve decided that attempting to reliably detect the visual size of the Block’s visual contents is impossible. This is due to inconsistencies in the DOM markup of each Block. See #16113 (comment) * Updates to remove scale by default in favour of opt in via prop As discussed here #16113 (comment), there is little point in having thumbnail preview and large popover preview showing the same thing. Update to introduce a prop to opt in to scaling the preview. By default the preview is no auto-scaled. Apply `true` value to `BlockPreview` to ensure that Block Styles popover preview is scaled to fit. * Adds scaleFactor prop to provide control for non dynamically scaled preview * Adjust scaleFactor for Block Styles preview * Fix to ensure hooks are called unconditionally to obey rules of Hooks See https://reactjs.org/docs/hooks-rules.html * Removes padding and border from preview on designer advice * Only apply dimensions to preview content when dynamically scaling * block-preview: a different approach attempt. * Correct typo in util function name * Seek the firstChild of the Block DOM node * Tidy up effect timers and improve comments * Dynamically calculate widths and offsets of preview container Removes hardcoded values. * Updates to account for widths of all Blocks passed into to preview Preivously we only considered a single Block scenario. However, the recent addition of multi block support for Previews means we need to ensure we’re measuring the widths of _all_ Blocks. * Revert class additions to Blocks * Adds optional scope to DOM utils. Use to limit scope in Block width comparison. * Update packages/block-editor/src/components/block-preview/index.js Co-Authored-By: Riad Benguella <benguella@gmail.com> * Allow prop based opt out from scaling * Fix to ensure smallest Block is found even if smaller than container Preivously we were default to the container width being the largest item. In fact we always want to determine the largest Block contents element and use that to determine the scale. * Remove unecessary Math.min usage * core/button: adjust dims of button wrapper * apply vertical alignment * set scale factor to 0.9 * rollback testing purpose comment * cpre/button: keep adjusting styles for preview * rename vars and css class names * adjust rebase * restore isScaled factor scale * set the scale adjustment in the proper place * update README file * core/button: tidy edit preview styles * coer/button: tweak button preview * preview-block: ensure make the preview visible. * block-preview: hide dropzone * core/button: adjust preview for thumb and full sizes * core/button: set same width for preview * core/button: because it's !important * core/button: set nowrap button in preview * core/button: set nowrap onlu for button * core/quote: adjust quote size * Make previews overflow to the bottom. Currently still has a bug where the large `.block-editor-block-switcher__preview` pane behaves like it's previewing a taller block, when it's not * Revert "core/button: set nowrap onlu for button" It breaks previews of long buttons This reverts commit 758468c. * Fix unit test * core/button: apply nowrap only to buttons * Try a fixed canvas width * Fix blocks editor styles * core/button: centering preview * core/button: adjust only into teh styles preview * block-preview: remove scaleAdjustment property * block-preview: hide inserte element in preview * block-preview: just pick up the first block to scale * block-preview: fix set tall class. X position (wip) * popover: remove commented lines * Refactor the preview * Remove debug code * simplify preview resets * Fix the preview recomputing * Vertical alignining small blocks * block-editor: restore viewportWidth as a property * Update Readme docs Props @marekhrabe. * Remove tests for now We'll revisit when we have a better idea what specifically we should be testing * block-preview: simplify comparision * Remove readme updates that break tests * Update docs properly. See 6f29c27
- Loading branch information