Skip to content

Commit

Permalink
Try: Fix dropcap behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmussen committed Feb 3, 2021
1 parent 92baa9b commit ede1948
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/block-library/src/paragraph/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ import {
InspectorControls,
RichText,
useBlockProps,
getFontSize,
//getFontSize,
__experimentalUseEditorFeature as useEditorFeature,
} from '@wordpress/block-editor';
import { createBlock } from '@wordpress/blocks';
import { useSelect } from '@wordpress/data';
import { useEffect, useRef, useState } from '@wordpress/element';
/*import { useSelect } from '@wordpress/data';
import { useEffect, useRef, useState } from '@wordpress/element';*/
import { formatLtr } from '@wordpress/icons';

function getComputedStyle( node, pseudo ) {
/*function getComputedStyle( node, pseudo ) {
return node.ownerDocument.defaultView.getComputedStyle( node, pseudo );
}
}*/

const name = 'core/paragraph';

Expand All @@ -49,7 +49,7 @@ function ParagraphRTLToolbar( { direction, setDirection } ) {
);
}

function useDropCapMinHeight( ref, isDisabled, dependencies ) {
/*function useDropCapMinHeight( ref, isDisabled, dependencies ) {
const [ minHeight, setMinHeight ] = useState();
useEffect( () => {
Expand All @@ -64,7 +64,7 @@ function useDropCapMinHeight( ref, isDisabled, dependencies ) {
}, [ isDisabled, ...dependencies ] );
return minHeight;
}
}*/

function ParagraphBlock( {
attributes,
Expand All @@ -79,11 +79,11 @@ function ParagraphBlock( {
direction,
dropCap,
placeholder,
fontSize,
style,
//fontSize,
//style,
} = attributes;
const isDropCapFeatureEnabled = useEditorFeature( 'typography.dropCap' );
const ref = useRef();
/*const ref = useRef();
const inlineFontSize = style?.fontSize;
const size = useSelect(
( select ) => {
Expand All @@ -93,14 +93,14 @@ function ParagraphBlock( {
[ fontSize, inlineFontSize ]
);
const hasDropCap = isDropCapFeatureEnabled && dropCap;
const minHeight = useDropCapMinHeight( ref, ! hasDropCap, [ size ] );
const minHeight = useDropCapMinHeight( ref, ! hasDropCap, [ size ] ); */
const blockProps = useBlockProps( {
ref,
//ref,
className: classnames( {
'has-drop-cap': dropCap,
[ `has-text-align-${ align }` ]: align,
} ),
style: { direction, minHeight },
style: { direction },
} );

return (
Expand Down
5 changes: 5 additions & 0 deletions packages/block-library/src/paragraph/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
font-style: normal;
}

// Prevent the dropcap from breaking out of the box when a background is applied.
p.has-drop-cap.has-background {
overflow: hidden;
}

p.has-background {
padding: $block-bg-padding--v $block-bg-padding--h;
}
Expand Down

0 comments on commit ede1948

Please sign in to comment.